15
- April
2018
Posted By : Zeng Yinghua (Sandy)
Use PowerShell monitor WSUS pool status

This is a quick post. One of my colleague asked if I have a script to check if WSUS pool is running, if not then start it. I think it’s properly related WSUS high CPU, high memory and high network usage issue what related to many other matter.

Anyway, this post is not about how to fix WSUS, Johan write a post about it, read it from here 

So, here is my little script, it just simply check WSUS pool running status, and start the WSUS pool if it is not running, and write the information to a log file.
You can put the script in Task Scheduler and use that to monitor when your WSUS pool is stopped, and make sure it starts if it was stopped.

As always, use as your own risk. (not sure what risk would be, but.. never know)

$File = "D:\Scripts\CheckWsusPool\WsusPool.log"
$Date = Get-Date
Add-Content -Value "$Date, Getting WsusPool Status -----------" -Path $File
$WsusPoolStatus = (Get-WebAppPoolState -Name WsusPool).Value
 
If ($WsusPoolStatus -eq "Started") {
    Add-Content -Value "WsusPool Status is $($WsusPoolStatus)" -Path $File
}
else {
    Add-Content -Value "WsusPool Status is $($WsusPoolStatus), trying start WsusPool" -Path $File
    try {
        Start-WebAppPool -Name WsusPool -Verbose
    }
    catch {
        $ErrorMessage = $_.Exception.Message
        Add-Content -Value "$ErrorMessage" -Path $File
    }
}

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.