SCOM Clear Cache Script

Posted by : at

Category : powershell


Article last updated on December 29th, 2021

The Clear SCOM Cache Script, which is located here:
https://github.com/blakedrumm/SCOM-Scripts-and-SQL/blob/master/Powershell/Clear-SCOMCache.ps1

The script without any modifications clears the SCOM cache only on the local server, nothing else.

Argument List Description
-All Optionally clear all caches that SCOM could potentially use that doesnt require a reboot. Flushing DNS, Purging Kerberos Tickets, Resetting NetBIOS over TCPIP Statistics. (Combine with -Reboot for a full clear cache)
-Reboot Optionally reset winsock catalog, stop the SCOM Services, clear SCOM Cache, then reboot the server. This will always perform on the local server last.
-Servers Optionally each Server you want to clear SCOM Cache on. Can be an Agent, Management Server, or SCOM Gateway. This will always perform on the local server last.
-Shutdown Optionally shutdown the server after clearing the SCOM cache. This will always perform on the local server last.
-Sleep Time in seconds to sleep between each server.

Examples

Clear all Gray SCOM Agents

#Get the SystemCenter Agent Class
$agent = Get-SCOMClass | where-object{$_.name -eq "microsoft.systemcenter.agent"}
#Get the grey agents
$objects = Get-SCOMMonitoringObject -class:$agent | where {$_.IsAvailable -eq $false}
.\Clear-SCOMCache.ps1 -Servers $objects

Clear SCOM cache on every Management Server in Management Group.

Get-SCOMManagementServer | .\Clear-SCOMCache.ps1

Clear SCOM cache on every Agent in the in Management Group.

Get-SCOMAgent | .\Clear-SCOMCache.ps1

Clear SCOM cache and reboot the Servers specified.

.\Clear-SCOMCache.ps1 -Servers AgentServer.contoso.com, ManagementServer.contoso.com -Reboot

Clear SCOM cache and shutdown the Servers specified.

.\Clear-SCOMCache.ps1 -Servers AgentServer.contoso.com, ManagementServer.contoso.com -Shutdown

Page Views


About Blake Drumm
Blake Drumm

I like to collaborate and work on projects. My skills with Powershell allow me to quickly develop automated solutions to suite my customers, and my own needs.

Email : bdrummtelco@gmail.com

Website : https://blakedrumm.com

About Blake Drumm

This is the personal technical blog for Blake Drumm. Currently primarly focused towards Microsoft System Center Enterprise Management Products. I am an Microsoft Support Engineer on the System Center North America Support Team. I am new to blogging. But this seems like a good time to start. July 6th, 2021 marks my first day as a Microsoft FTE converting from a contractor. I had been working as a contractor since January 2020 (1 year, 5 months, 22 days)!

Follow @blakedrumm
Useful Links