Skip to content

Commit 1295f90

Browse files
authored
Update Clear-SCOMCache.ps1
1 parent 95efae9 commit 1295f90

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

Powershell/Clear-SCOMCache.ps1

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,52 +92,56 @@ BEGIN
9292
}
9393
PROCESS
9494
{
95-
$setdefault = $false
96-
foreach ($Server in $input)
97-
{
98-
if ($Server.GetType().Name -eq 'ManagementServer')
99-
{
100-
if (!$setdefault)
101-
{
102-
$Servers = @()
103-
$setdefault = $true
104-
}
105-
$Servers += $Server.DisplayName
106-
}
107-
elseif ($Server.GetType().Name -eq 'AgentManagedComputer')
108-
{
109-
if (!$setdefault)
110-
{
111-
$Servers = @()
112-
$setdefault = $true
113-
}
114-
$Servers += $Server.DisplayName
115-
}
116-
elseif ($Server.GetType().Name -eq 'MonitoringObject')
117-
{
118-
if (!$setdefault)
119-
{
120-
$Servers = @()
121-
$setdefault = $true
122-
}
123-
$Servers += $Server.DisplayName
124-
}
125-
126-
}
12795
Function Clear-SCOMCache
12896
{
12997
param
13098
(
13199
[Parameter(Mandatory = $false,
132-
Position = 1)]
100+
ValueFromPipeline = $true,
101+
Position = 1,
102+
HelpMessage = '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.')]
133103
[String[]]$Servers,
134104
[Parameter(Mandatory = $false,
135-
Position = 2)]
105+
Position = 2,
106+
HelpMessage = 'Optionally reboot the server after stopping the SCOM Services and clearing SCOM Cache. This will always perform on the local server last.')]
136107
[Switch]$Reboot,
137108
[Parameter(Mandatory = $false,
138-
Position = 3)]
109+
Position = 3,
110+
HelpMessage = 'Optionally clear all caches that SCOM could potentially use. Flushing DNS, Purging Kerberos Tickets, Resetting NetBIOS over TCPIP Statistics.')]
139111
[Switch]$All
140112
)
113+
$setdefault = $false
114+
foreach ($Server in $input)
115+
{
116+
if ($Server.GetType().Name -eq 'ManagementServer')
117+
{
118+
if (!$setdefault)
119+
{
120+
$Servers = @()
121+
$setdefault = $true
122+
}
123+
$Servers += $Server.DisplayName
124+
}
125+
elseif ($Server.GetType().Name -eq 'AgentManagedComputer')
126+
{
127+
if (!$setdefault)
128+
{
129+
$Servers = @()
130+
$setdefault = $true
131+
}
132+
$Servers += $Server.DisplayName
133+
}
134+
elseif ($Server.GetType().Name -eq 'MonitoringObject')
135+
{
136+
if (!$setdefault)
137+
{
138+
$Servers = @()
139+
$setdefault = $true
140+
}
141+
$Servers += $Server.DisplayName
142+
}
143+
144+
}
141145
if (!$Servers)
142146
{
143147
$Servers = $env:COMPUTERNAME
@@ -513,7 +517,7 @@ PROCESS
513517
}
514518
else
515519
{
516-
<# Edit line 510 to modify the default command run when this script is executed.
520+
<# Edit line 525 to modify the default command run when this script is executed.
517521
518522
Example:
519523
Clear-SCOMCache -Servers Agent1.contoso.com, Agent2.contoso.com, MS1.contoso.com, MS2.contoso.com

0 commit comments

Comments
 (0)