Which Microsoft Excahnge Service Do I Stop To Stop Mail Selivery
Equally a old Commutation Admin and electric current Exchange Consultant, I have always looked for a way to make my life easier when managing Substitution Servers. This sometimes included working with services in Exchange, having to start them or stop them depending on what I Was trying to do.
For case, I've just rebooted an Substitution server and need a convenient way to start up all of the services. One way is to write up a batch file and run it whenever you want. I've washed this on more than servers than I tin can count. The other option is to create a more versatile scripting language to start up merely those services you demand to. This is what I've created in PowerShell:
# Service Start Script # # v1.one # For Substitution 20xx Servers # $services = Get-WmiObject Win32_Service foreach ($line in $services) { $service = $line.displayname $status = $line.state $startup = $line.startmode if ($service -like "Microsoft Exchange*") { if (($condition -eq "Stopped") -and ($startup -eq "Auto")) { write-host $service" needs to exist started. Starting information technology now." start-service $service } # Added for Edge Transport Server if ($service -like "Active Directory Web Services") { if (($status -eq "Stopped") -and ($startup -eq "Auto")) { write-host $service" needs to be started. Starting information technology now." start-service $service } } } } foreach ($line in $services) { $service = $line.displayname $status = $line.state $startup = $line.startmode if ($service -like "Microsoft Commutation*") { get-service $service } }
Note, this script gets a list of services using WMI and searches for a sure design in the display name of the service which in this instance is 'Microsoft Exchange". The main reason I used WMI is that get-service will non supply enough information such as the startup blazon (automatic/transmission/disabled).
The script volition also cheque to encounter if the service is started. This gives us line 13 where we check for a service with a startup type of 'Automatic' and if the service state is 'Stopped'. If the service meets both criteria, then the script will attempt to start the service.
One time all the services for Exchange accept tried to outset, the script will bank check the services for a current state.
Stopping Services
For stopping the services, nosotros can utilize pretty much the same lawmaking adjusting for service state of started and then stopping the service.
# Service Finish Script # # v1.1 # For Exchange 20xx Servers # $services = Get-WmiObject Win32_Service foreach ($line in $services) { $service = $line.displayname $condition = $line.state $startup = $line.startmode if ($service -like "Microsoft Substitution*") { if (($condition -eq "Running") -and ($startup -eq "Machine")) { write-host $service" needs to be stopped. Stopping it now." cease-service $service -force } # Added for Edge Transport Server if ($service -like "Active Directory Spider web Services") { if (($status -eq "Running") -and ($startup -eq "Auto")) { write-host $service" needs to be stopped. Stopping information technology at present." stop-service $service -force } } } } foreach ($line in $services) { $service = $line.displayname $status = $line.land $startup = $line.startmode if ($service -like "Microsoft Substitution*") { become-service $service } }
To make this even fancier, y'all could potentially add together a bill of fare system to select whether to starting time or stop services. That'south upwardly to you.
*** Update ***
Corrections made later a comment from a reader.
- Added line for Edge Send service that is unique to that part.
- Added the "-force" parameter to the Stop Service command.
- Added "Running" every bit my filter was using the incorrect criteria.
Which Microsoft Excahnge Service Do I Stop To Stop Mail Selivery,
Source: https://www.powershellgeek.com/2014/02/09/starting-and-stopping-exchange-services/
Posted by: arnoldforthemight.blogspot.com
0 Response to "Which Microsoft Excahnge Service Do I Stop To Stop Mail Selivery"
Post a Comment