@@ -155,6 +155,10 @@ PROCESS
155155 )
156156 BEGIN
157157 {
158+ trap
159+ {
160+ Write-Host $error [0 ] - ForegroundColor Yellow
161+ }
158162 Function Time-Stamp
159163 {
160164 $TimeStamp = Get-Date - Format " MM/dd/yyyy hh:mm:ss tt"
@@ -450,26 +454,55 @@ PROCESS
450454 }
451455 else
452456 {
453- try
457+ if ( $All )
454458 {
455- Invoke-Command - ErrorAction Stop - ComputerName $server - ArgumentList $InnerClearSCOMCacheFunctionScript - ScriptBlock {
456- Param ($script )
457- . ([ScriptBlock ]::Create($script ))
458- return Inner- ClearSCOMCache
459+ try
460+ {
461+ Invoke-Command - ErrorAction Stop - ComputerName $server - ArgumentList $InnerClearSCOMCacheFunctionScript - ScriptBlock {
462+ Param ($script )
463+ . ([ScriptBlock ]::Create($script ))
464+ return Inner- ClearSCOMCache - All
465+ }
459466 }
467+ catch { Write-Host $Error [0 ] - ForegroundColor Red }
468+ }
469+ else
470+ {
471+ try
472+ {
473+ Invoke-Command - ErrorAction Stop - ComputerName $server - ArgumentList $InnerClearSCOMCacheFunctionScript - ScriptBlock {
474+ Param ($script )
475+ . ([ScriptBlock ]::Create($script ))
476+ return Inner- ClearSCOMCache
477+ }
478+ }
479+ catch { Write-Host $Error [0 ] - ForegroundColor Red }
460480 }
461- catch { Write-Host $Error [0 ] - ForegroundColor Red }
462481 continue
463482 }
464483 if ($containslocal )
465484 {
466- Inner- ClearSCOMCache
485+ if ($All )
486+ {
487+ Inner- ClearSCOMCache - All
488+ }
489+ else
490+ {
491+ Inner- ClearSCOMCache
492+ }
467493 $completedlocally = $true
468494 }
469495 }
470496 if ($containslocal -and ! $completedlocally )
471497 {
472- Inner- ClearSCOMCache
498+ if ($All )
499+ {
500+ Inner- ClearSCOMCache - All
501+ }
502+ else
503+ {
504+ Inner- ClearSCOMCache
505+ }
473506 }
474507
475508 }
@@ -480,7 +513,7 @@ PROCESS
480513 }
481514 else
482515 {
483- <# Edit line 479 to modify the default command run when this script is executed.
516+ <# Edit line 510 to modify the default command run when this script is executed.
484517
485518 Example:
486519 Clear-SCOMCache -Servers Agent1.contoso.com, Agent2.contoso.com, MS1.contoso.com, MS2.contoso.com
0 commit comments