What is the best way to get the mailbox database size and available space? Why…
Restart Exchange Servers IIS with PowerShell
Microsoft Exchange Server depends on Internet Information Services (IIS). Sometimes you have to restart IIS, which you can do through IIS management or the console (Command Prompt or PowerShell). But what if you have more than multiple Exchange Servers running, and you have to restart IIS on all of them? In this article, you will learn how to restart the IIS service remotely on all Exchange Servers with PowerShell.
Table of contents
Restart IIS Exchange Server PowerShell script
The Restart-ExchangeIIS.ps1 PowerShell script will get all the Exchange Servers. After that, it will restart IIS on the Exchange Servers and show the IIS status.
Note: The Restart-ExchangeIIS.ps1 PowerShell script must be run on a Management Server or Exchange Server because you need the Exchange Management tools installed.
Prepare restart Exchange Server IIS PowerShell script
Download the script Restart-ExchangeIIS.ps1 or copy and paste the below code in Notepad. Give it the name Restart-ExchangeIIS.ps1 and place it in the C:\scripts folder. Create a scripts folder if you don’t have one.
Ensure the file is unblocked to prevent errors when running the script. Read more in the article Not digitally signed error when running PowerShell script.
# Load Exchange Management Shell PowerShell Snap-In
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
# Get All Exchange Servers
$Servers = Get-ExchangeServer
# Go through the list and restart one by one
foreach ($Server in $Servers) {
Write-Host "Restarting IIS on server: $($Server.Name)" -ForegroundColor Green
IISRESET $Server.Name
# Optional: Get the Status
Write-Host "IIS status for server $($server):"
IISRESET $server.Name /status
}
Write-host "IIS restarted on all Exchange Servers." -ForegroundColor Green
It will look like this.
Run restart Exchange Server IIS PowerShell script
Run Exchange Management Shell as administrator. Change the path to the scripts folder. Run the PowerShell script to restart IIS on all Exchange Servers. Wait till it completes.
[PS] C:\>cd C:\scripts
[PS] C:\scripts>.\Restart-ExchangeIIS.ps1
The below screen shows how it looks when running the script in an organization with two Exchange Servers (EX01-2019/EX02-2019) running in the organization.
Did this help you to restart IIS on the Exchange Servers?
Read more: Restart Exchange Server services through PowerShell »
Conclusion
You learned how to restart Exchange Servers IIS with PowerShell. Save yourself time and run the script if you have more than one Exchange Server running in the organization and want to restart IIS on all of them.
Did you enjoy this article? You may also like An error occurred while creating the IIS virtual directory. Don’t forget to follow us and share this article.
Thank you for your sharing
just if posible to have script to restart only below IIS servises for all Exhange Servers
Restart-WebAppPool -name MSExchangePowerShellFrontEndAppPool
Restart-WebAppPool -name MSExchangePowerShellAppPool
Great articles. please write as much as u can. almost I am starting and ending my day with following your articles