Skip to content

PowerShell Script Failed To Run

Emre Guclu edited this page Dec 3, 2020 · 2 revisions

Finding out the Workflows Generated issues

The following script parses the Alert Description using a regex to grab the workflow name.

Get-SCOMAlert -Name 'Power Shell Script failed to run' | Select-Object -Property MonitoringObjectDisplayName,MonitoringObjectPath,TimeAdded,@{Name='WorkflowName';Expression = {

if ($_.Context -match '(?m)^Workflow\sName\:\s(\S+)') {

$Matches[1]

} else {'N/A'}

 
}
} | Group-Object  -Property WorkflowName -NoElement | Sort-Object -Descending -Property Count | ft -AutoSize

Sample Result is as follows

Count Name                                                                             
----- ----                                                                             
   12 Microsoft.SystemCenter.HealthService.SCOMpercentageCPUTimeMonitor                
   12 Microsoft.SystemCenter.HealthService.SCOMpercentageCPUTimeCollection             
    2 Microsoft.Windows.Server.10.0.NetworkAdapter.PercentBandwidthUsedTotal.Collection
    2 Microsoft.Windows.Server.10.0.NetworkAdapter.PercentBandwidthUsedTotal           
    2 N/A                                                                              
    1 Microsoft.SystemCenter.DiscoveryHealthServiceCommunication                       
    1 Microsoft.SystemCenter.DiscoverADManagedComputer         
 

Finding out the Workflows Generated issues with Servers

The following script is very similar to the above but this time also includes per computer count in the groups.

Get-SCOMAlert -Name 'Power Shell Script failed to run' | Select-Object -Property MonitoringObjectDisplayName,MonitoringObjectPath,TimeAdded,@{Name='WorkflowName';Expression = {

if ($_.Context -match '(?m)^Workflow\sName\:\s(\S+)') {

$Matches[1]

} else {'N/A'}

 
}
} | Group-Object  -Property WorkflowName,MonitoringObjectPath -NoElement | Sort-Object -Descending -Property Count | ft -AutoSize

Side bar

Clone this wiki locally