Book Image

Microsoft System Center Powershell Essentials

Book Image

Microsoft System Center Powershell Essentials

Overview of this book

Table of Contents (15 chapters)
Microsoft System Center PowerShell Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
4
Administration of Operations Manager through PowerShell
Index

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