SCOM 2012: Get all computers with a specific alert (PowerShell)

Standard

Yesterday I received a question about: ‘Can you give me all unique computers with the following active alert’. My answer was ‘Yes, I Can!’. My first idea was to solve this with a PowerShell script and here it is. A short script of 2 lines which gives you all unique agents with the alert: ‘Workflow Initialization: Failed to start a workflow that runs a process or script’.

Import-Module OperationsManager
New-SCOMManagementGroupConnection -Computername "<<MGMT_SRV>>"

#Get all alerts complaining about missing credentials "System Center Management Health Service Credentials Not Found Alert Message"
$hosts = Get-SCOMAlert | Where-Object {$_.Name -eq "Workflow Initialization: Failed to start a workflow that runs a process or script" -and $_.ResolutionState -ne '255'} | Select PrincipalName
$hosts.GetEnumerator() | Sort-Object -Property PrincipalName -Unique

Before you can use this script in your environment you have to change the string: <<MGMT_SRV>> and probably the name of the alert. The string <<MGMT_SRV>> needs to be replaced with one of your SCOM management servers.

Have fun!

 

One thought on “SCOM 2012: Get all computers with a specific alert (PowerShell)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.