Just create a new one grid dashboard with a powershell grid widget and paste the following code :
$Class = Get-SCOMClass -DisplayName 'Windows Server'$Instance = Get-SCOMClassInstance -Class $Class
$Events = Get-SCOMEvent -Instance $Instance -EventId 1074 | Sort-Object TimeAdded -Descending | Select -First 50
$i = 0
foreach ($Event in $Events) {
$EventDescription = 'User : ' + [string]$Event.Parameters[6] + ' || Type : ' + [string]$Event.Parameters[4] + ' || Reason : ' + [string]$Event.Parameters[5]
$TimeAdded = $Event.TimeAdded
$LoggingComputer = [string]$Event.LoggingComputer
$dataObject = $ScriptContext.CreateInstance("xsd://foo!bar/baz")
$dataObject["Id"]=$i.toString()
$dataObject["TimeAdded"]=$TimeAdded
$dataObject["LoggingComputer"]=$LoggingComputer
$dataObject["Description"]=$EventDescription
$ScriptContext.ReturnCollection.Add($dataObject)
$i++
}
I've made this for a event collection i've in a customer for restart events (1074) - you might change as you like.
And enjoy the show :)
No comments:
Post a Comment