skip to Main Content

Restart Exchange services with PowerShell script

Clients are not connecting to the Exchange Server after an Exchange update. When you browse to Exchange Server OWA and ECP, it’s showing errors or a blank page. The first thing you need to check is if the Exchange services are running. Let’s have a look at the RestartExchangeServices PowerShell script that will help you to restart Exchange services and a little more.

Exchange update breaks Exchange services

You did install an Exchange security patch or Cumulative Update, and after a reboot, Exchange Server is not working. Your first guess is that the Exchange Server services are not up and running. You did try another reboot, but that didn’t help to reset the status of the services automatically. Another option that you already did is to restart Exchange Server services through PowerShell. But that didn’t work either. Why is that? That’s because it takes more than only Exchange Server services to be up and running.

Prepare restart Exchange services PowerShell script

Copy the following code and paste it in Notepad. Save the file type as RestartExchangeServices.ps1. You can also download the RestartExchangeServices.ps1 script (direct link).

# Automatic services
$auto = "MSExchangeADTopology",
"MSExchangeAntispamUpdate",
"MSExchangeDagMgmt",
"MSExchangeDiagnostics",
"MSExchangeEdgeSync",
"MSExchangeFrontEndTransport",
"MSExchangeHM",
"MSExchangeImap4",
"MSExchangeIMAP4BE",
"MSExchangeIS",
"MSExchangeMailboxAssistants",
"MSExchangeMailboxReplication",
"MSExchangeDelivery",
"MSExchangeSubmission",
"MSExchangeRepl",
"MSExchangeRPC",
"MSExchangeFastSearch",
"HostControllerService",
"MSExchangeServiceHost",
"MSExchangeThrottling",
"MSExchangeTransport",
"MSExchangeTransportLogSearch",
"MSExchangeUM",
"MSExchangeUMCR",
"FMS",
"IISADMIN",
"RemoteRegistry",
"SearchExchangeTracing",
"Winmgmt",
"W3SVC"

# Manual services
$man = "MSExchangePop3",
"MSExchangePOP3BE",
"wsbexchange",
"AppIDSvc",
"pla"

# Enable Services
foreach ($service in $auto) {
   Set-Service -Name $service -StartupType Automatic
   Write-Host "Enabling "$service
}
foreach ($service2 in $man) {
   Set-Service -Name $service2 -StartupType Manual
   Write-Host "Enabling "$service2
}

# Start Services
foreach ($service in $auto) {
   Start-Service -Name $service
   Write-Host "Starting "$service 
}

Place the PowerShell script in the C:\scripts folder. If you don’t have a scripts folder, create one.

Restart Exchange services with PowerShell script

Run restart Exchange services PowerShell script

On the Exchange Server, run Windows PowerShell as administrator. Change the directory to the scripts folder and run the script. It will go through all the services in the script and set the services to manual or automatic. After that, it will start the services.

PS C:\> cd C:\scripts
PS C:\scripts> .\RestartExchangeServices.ps1

Do you get access denied errors, or it fails to start the services? Go to Windows Services Manager (services.msc) and enable the services manually.

After you run the script, try connecting to Exchange Server. This time it will work.

Restart Exchange services with PowerShell script Exchange Admin Center

Read more: Install Exchange certificate with PowerShell »

Conclusion

In this article, you learned how to restart Exchange Services with PowerShell script. Most of the time, this happens after you install an Exchange update. That’s because you didn’t run the Exchange setup as administrator. The next time an Exchange update breaks your clients from connecting to Exchange Server, run the script and try again.

Did you enjoy this article? You may also like Create mailbox database Exchange 2016. Don’t forget to follow us.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top