четверг, 19 ноября 2015 г.

SCOM PowerShell porn

Hi,

Just wanted to share with everyone some PowerShell craziness I used to analyze management pack full of overrides. This command will process all overrides in a specified Management Pack(s) and will show the corresponding Rule/Monitor ID and Display name, Rule/Monitor enabled state, display name for the context of the override, override parameter/property and its value. This thing can process any override, no matter which type - Monitor Property, Monitor Configuration, Rule Property or Rule Configuration. You can add export-csv instead of the last select to put everything in the nice spreadsheet.

Get-ScomOverride | ? {$_.Identifier -like "*Veeam.overrides*"} | Select name, @{n='Rule';e={if($_.Rule){(Get-ScomRule -id $_.Rule.Id).displayname}else{(Get-ScomMonitor -id $_.Monitor.Id).displayname}}}, @{n='RuleID';e={if($_.Rule){(Get-ScomRule -id $_.Rule.Id).name}else{(Get-ScomMonitor -id $_.Monitor.Id).name}}}, @{n='RuleEnabled';e={if($_.Rule){(Get-ScomRule -id $_.Rule.Id).Enabled}else{(Get-ScomMonitor -id $_.Monitor.Id).Enabled}}}, @{n='Context2';e={if($_.Context){(Get-ScomClass -id $_.Context.Id).displayname}}}, @{n='PropPar';e={if($_.Property){$_.Property}else{$_.Parameter}}}, Value | Sort RuleEnabled, Rule | Select Rule, RuleEnabled, PropPar, Value