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 } }
Hi,
Thanks for the script. However, as a greenhorn in this all I only get an error message and the status dies not change. Would you mind having a look and telling me what goes wrong? Thanks a lot
The script itself is unchanged except of the path which is slightly different. OS is Win Server 2019 Standard.
Cheers, Dan
PS E:\Scripts\CheckWsusPool> E:\Scripts\CheckWsusPool\CheckWsusPool.ps1
Process should have elevated status to access IIS configuration data.
get-webitemstate : Cannot find drive. A drive with the name ‘IIS’ does not exist.
At E:\Scripts\CheckWsusPool\CheckWsusPool.ps1:4 char:1
+ $WsusPoolStatus = (Get-WebAppPoolState -Name WsusPool).Value
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (IIS:String) [Get-WebItemState], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.IIs.PowerShell.Provider.GetItemStateCommand
VERBOSE: Performing the operation “Set Item” on target “Item: ConfirmPreference Value: High”.
Hello Dan,
Your error output said “Process should have elevated status to access IIS configuration data.”. Means it needs to run as the highest privilege in the Schedule task. If you are testing the script manually, you need to run PowerShell as Admin.