Category: PSOL

PowerShell OneLiner

PSOL: Get-SNMPDevices

Quick and easy way to get a list of all OpsMgr monitored SNMP devices

Get-MonitoringClass -name 'System.NetworkDevice' | Get-MonitoringObject | Format-Table PathName, DisplayName

PSOL: Read web page

If you need to output something from a webpage via Powershell, then .NET is a easy way to do it.

Write-Host ([String] (New-Object Net.WebClient).DownloadString('http://snowland.se/demo/'))

PSOL: Resolve informational alerts without repeatcount

To get rid of a large number of alerts in SCOM you can of course use PowerShell…

This script will take informational alerts without any repeats that are 24 hours old and simply resolve them with a small comment.

get-alert | where { $_.Severity -eq 0 -and $_.RepeatCount -eq 0 -and $_.ResolutionState -eq '0' -and $_.LastModified -lt (get-date).AddHours(-24)} | Resolve-Alert -comment "Alert resovled via script (24 hours old informational alert without repeatcount)" | Format-Table MonitoringObjectPath, Name, TimeRaised

(Change “$_.RepeatCount -eq 0″ to “$_.RepeatCount -lt 3″ to get alerts with less then 3 repeats)