Listing past alerts
The following code will list all the alerts generated a day before you run the script. You can make it according to your custom date just by changing the value that we add to the date (-1
in the current example) in the following script:
$AllAlerts = Get-SCOMAlert $AlertDateYesterdayBegin = [DateTime]::Today.AddDays(-1)$AlertDateYesterdayEnd = [DateTime]::Today.AddDays(-1).AddSeconds(86399) $YesterdayAlerts = @($AllAlertsW | where {$_.TimeRaised -ge $AlertDateYesterdayBegin -and $_.TimeRaised -lt $AlertDateYesterdayEnd}) $YesterdayAlerts