How can I flush an Agent Cache using PowerShell was the question of the day… ok, plenty of ways to do that, but here’s a basic pointer in the right direction. Remember, you’ll want to stop the healthservice first, and start it after this code has run…
# The name of the Health Service State folder where the Config is downloaded to/stored on an Agent.
$MMAgentHSTFolder = “Health Service State”
# Retrieve the path of the installation folder for the SCOM Agent from the registry.
$reg = Get-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\”
$MMAgentInstallDirectory = $reg.InstallDirectory
# Populate the full path to the folder.
$MMAgentHSTPath = $MMAgentInstallDirectory + $MMAgentHSTFolder
# Delete all of the files in the Health State Folder and any subdirectories.
Remove-Item -Path $MMAgentHSTPath\* -recurse
Of course, if you prefer to do this all on one line you could easily do that too…have fun!