How to clear SCOM agent cache

Situation: The client has Microsoft System center 2019. They have some issues such as servers in Pending management with status of “Installation in Progress ” and never process. Also, some SCOM agents show “gray” state. In these cases, you may want to clear SCOM agent cache by running Powershell commands.

  1. Run Powershell as administrator.
  2. Run these commands:

[powershell]
$Server = Read-Host "Please enter your server name"
$Service = Get-Service -Name HealthService -ComputerName $Server

Write-Host "`n1. Stopping the Monitoring Agent service…`n"

Stop-Service $Service

Write-Host "2. Checking the Monitoring Agent service status:

"Write-Host "`nMonitoring Agent service status: "-nonewline;
Write-Host
$Service.Status -Fore Red

Start-Sleep -s 3

Write-Host "`n3. Renaming the existing ‘Health Service State’ folder to
‘Health Service State Old’ `n

"Rename-Item -Path "\\$Server\C$\Program Files\Microsoft Monitoring
Agent\Agent\Health Service State" -NewName "Health Service State Old

"Write-Host "4. Starting the Monitoring Agent service…`n"

Start-Service $Service

Start-Sleep -s 3

Write-Host "5. Checking the Monitoring Agent service status:"

Write-Host "`nMonitoring Agent service status: "-nonewline;
Write-Host
$Service.Status -Fore Green

Write-Host "`n6. Removing the ‘Health Service State Old’ folder.

"Remove-Item -Path "\\$Server\C$\Program Files\Microsoft Monitoring
Agent\Agent\Health Service State Old" -Recurse

Write-Host "`n7. Done!"
[/powershell]

3. Restart all SCOM services.

Published by

Bob Lin

Bob Lin, Chicagotech-MVP, MCSE & CNE Data recovery, Windows OS Recovery, Networking, and Computer Troubleshooting on http://www.ChicagoTech.net How to Install and Configure Windows, VMware, Virtualization and Cisco on http://www.HowToNetworking.com