Manually clearing your SCOM agent cache

There are occasions when a SCOM agent goes into a "not monitored" or "gray" state, to troubleshoot this we normally perform a "clear cache" of the agent.

pic1
7139f-xxxxxx.jpg

I have created a simple script that clears the cache on the monitored server agent, this script can be run both locally and remotely.

The script will do the following steps:

1. Stop the Microsoft Monitoring Agent service.
2. Check the Microsoft Monitoring Agent service status.
3. Rename the existing "Health Service State" folder.
4. Start the Microsoft Monitoring Agent service.
5. Check the Microsoft Monitoring Agent service status.
6. Remove the old "Health Service State" folder.
7. Done.

The Script

[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]

Download the script from here: SCOM Agent Clear Cache

Previous
Previous

Update Rollup 6 for System Center 2016 has been released!

Next
Next

What's new in System Center 2019?