Показаны сообщения с ярлыком SCOM. Показать все сообщения
Показаны сообщения с ярлыком SCOM. Показать все сообщения

четверг, 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

пятница, 26 июня 2015 г.

Remove specific data from XML with PowerShell. Records from SCOM Default User MP for example

Hi,

Just to save for myself too. I was playing with XML support in PowerShell and was able to use the following to delete part of the XML. This is very useful, especialy for dealing with Operations Manager Default User Management Pack. You can select data for a specific Management Pack and delete it, so that the desired Management pack can be removed without deleting the Default User MP.
$xml = [xml](Get-Content ".\Microsoft.SystemCenter.OperationsManager.DefaultUser.xml")
$xml.ManagementPack.Monitoring.Overrides.MonitorPropertyOverride | ? {$_.Monitor -like "*Exchange*" -or $_.Context -like "*Exchange*"} | % {$_.ParentNode.RemoveChild($_)}
You can also export these contents before deleting. Like that
$xml.ManagementPack.Monitoring.Overrides.MonitorPropertyOverride | ? {$_.Monitor -like "*Exchange*" -or $_.Context -like "*Exchange*"} | % {$_.OuterXML} | Out-File .\MPO.xml

 To save the update MP, use Save method:
$xml.Save("FullPath")