Exchange Migration – Restart Apppool

Here is a gret script that restarts the Autodiscover Apppool every 5 minutes until there isn’t any mailboxes left on the oldserver. This one works for Exchange 2016 and 2013

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;

$i = 1
$mail = (get-mailbox -server "kakster-oldexchange").count
Restart-WebAppPool MSExchangeAutodiscoverAppPool
Write-host "Restarting AppPool" -ForegroundColor GREEN
"Waiting for 3 minutes"
Start-Sleep -Seconds 300
"Now `$mail is $mail"
Write-host "Running script for the $i time" -ForegrondColor Red
} Until( $mail -eq 0)

Was this helpful please rate 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)