Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When you update the Exchange Server, you need to restart all the services for the updates to take effect. When you install Security Updates or Cumulative Updates, there are a lot of changes that will occur on the Exchange Server. This requires stopping of the services until the updates are being installed.
In a normal scenario, these services will restart with no issues. But some updates require to restart the server as well. After a reboot, some services might not start. In such a scenario, you have to either restart the services one-by-one or restart the server hoping that all services will start.
Installation of third-party applications, which integrate with the Exchange Server, would require restarting of some Exchange Server services. For example; if you are installing a third-party application for email encryption or setting up a cloud service, you need to make changes to the router or connector in your Exchange Server. So, you need to restart the specific services for the changes to take effect.
Likewise, you need to restart the services if you’re installing applications for external spam or malware filtering on the server or cloud and applications to backup outgoing and incoming emails for journaling or keeping a copy of the data.
In this article, we will be going to discuss the ways on how to restart the Exchange services with PowerShell script.
Ways to Restart the Exchange Services with PowerShell
There are different ways to restart the Exchange Server services. One way is manually restart the services one-by-one by opening the Services Management Console and confirming that the services have been started. This will take time and you need to wait for all the services to start to confirm that all went well. Also, there is a chance that you might miss a service. The other option is to use a batch file to automatically start the services using the NET START <name of service>.
Using a PowerShell script, you can automate the process of restarting the services and also introduce a lot of functionality and notifications. For example, you can add a check if the service doesn’t start, and to retry automatically, send a notification if the service cannot start, and other validations and verifications.
In this article, we will be going through the option to setup a basic script to restart the services.
There are different services in Windows which are dependent on Exchange Server. Also, there are services in Exchange Server which are set to automatic and others as manual or disabled. These depend on the setup of the business.
We will be taking a default setup that you can customize as per your requirements. Open Notepad.exe or the PowerShell ISE as Administrator and type the following script.
# Automatic starting 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 startup services
$man = "MSExchangePop3",
"MSExchangePOP3BE",
"wsbexchange",
"AppIDSvc",
"pla"
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
}
foreach ($service in $auto) {
Start-Service -Name $service
Write-Host "Starting "$service
}
Now, depending on the Exchange Server version, the services need to be updated. The script first sets the services specified as automatic or manual. Then, for each service which is set to automatic, it will start the service.
Once all is ready, save the file as a PowerShell script with the .ps1 extension. To run it, open PowerShell as Administrator and run the command ./<filename>.ps1.
This is the basic script to restart the services which you can automate with scheduled tasks, add custom validations, etc.
How to Recover if the Services won’t Start?
Sometimes, you may face a situation where the installation of a cumulative update or a third-party software renders your Exchange Server unusable. There can be issues with the Exchange Server or the operating system itself. You need to also consider issues with the underlying hardware.
You can try to reinstall the Exchange Server from scratch and import the databases. But you need to make sure that you have enough resources. Also, this would take a considerate amount of time. If there are corruption issues or missing files after an update, you can use the tools like EseUtil Command to try to bring the databases to a healthy state using soft recovery or hard recovery. However, this cannot guarantee that the database will mount. Databases in Exchange are not easily ported. You could end up with a huge expense trying to restore the services.
Another option is to restore the server from the last healthy backup. This will resolve the problem but you will end up losing all the data from the time of the backup till the issue arises.