Quick Tip: Restarting all Microsoft Exchange services

There are times when you need to restart all Exchange related services so here are 2 small scripts that will help you achieve this without going over each service in the Services mmc.

Of course restarting the “Microsoft Exchange Active Directory Topology” will restart a most of them but these 2 will restart them all.

 

Restarting All Running Services
This will get all services starting with MSexchange that are running and restart them.

$services = Get-Service | ? { $_.name -like "MSExchange*" -and $_.Status -eq "Running"}
foreach ($service in $services) {Restart-Service $service.name -Force}

Restarting All Running Services with startup type Automatic
Although the above script should be enough in most cases, it will not restart any Microsoft Exchange related service that is supposed be running but is not for any reason. Here is another version of the script that would take care of this issue, note that we are looking for all services starting with MSExchange with startup type Automatic and restarting them

$services = get-wmiobject win32_service | ? {$_.name -like "MSExchange*" -and $_.StartMode -eq "Auto"}
foreach ($service in $services) {Restart-Service $service.name -Force}

That’s it for now