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

I have been working in IT consultancy and solution integration since 1998 and I consider myself lucky to be, one in a few, making a living out of my passion. I am also member of the famous Experts Exchange (profile here) online community where I try my best to share what I have learned along the road.

Tagged with: , , , ,
Posted in Messaging & Collaboration
  • Test

    A reboot is faster

  • GET

    Thanks for script. Is it a “cmdlet” or something I put right into a .bat/.cmd file?

    • http://whygoogle.me/ akhater

      you can put it in a .ps1

Tweets Tweets