Hi,
how can I get Targets, Alarm Rules information from Alarm Definition.
Please help!!
Get-AlarmDefinition -PipelineVariable alarm |
ForEach-Object -Process {
Get-AlarmAction -AlarmDefinition $_ -PipelineVariable action |
ForEach-Object -Process {
Get-AlarmActionTrigger -AlarmAction $action |
select @{N='Alarm';E={$alarm.Name}},
@{N='Description';E={$alarm.Description}},
@{N='Enabled';E={$alarm.Enabled}},
@{N='Last Modified';E={$alarm.ExtensionData.Info.LastModifiedTime}},
@{N='Last Modified By';E={$alarm.ExtensionData.Info.LastModifiedUser}},
@{N='Entity';E={$alarm.Entity}},
@{N='Expression';E={
($alarm.ExtensionData.Info.Expression.Expression |
ForEach-Object -Process {"{0} ({1}) - {2} - {3}" -f $_.EventType,
$_.EventTypeId,
$_.ObjectType,
([VMware.Vim.ManagedEntityStatus]$_.Status.value__)}) -join '|'
}},
@{N='Trigger';E={
"{0}:{1}->{2} (Repeat={3})" -f $action.ActionType,
$_.StartStatus,
$_.EndStatus,
$_.Repeat
}}
}
} | Sort-Object -Property Alarm -Unique | Export-Csv -Path .\POC_2_Alarms_Export_$($mydate).csv -NoTypeInformation -UseCulture