Reputation: 685
I have a list of event id which I need to query on Multiple Server using PowerShell 2.0. Below is the script:
$a = Get-Date
$b = $a.AddDays(-1)
$b = $b.ToShortDateString();
$StartTime = "10:00:00 PM"
$EndTime = "11:00:00 PM"
$SMS_000 = "XXSMS01"
$SMS_SQL_000 = "XXXXXSQL01"
Get-EventLog -ComputerName $SMS_000, $SMS_SQL_000 -LogName Application -After $b -Before $b -Source "SMS Server" | ?{$_.EventID -eq 5055 -and $_.Event -eq 6829}
I would like to store the result into an obj which I shall then be passing to creation of an HTML report. The above is just a part of the process. Thanks!
Upvotes: 1
Views: 12542
Reputation: 200203
$events = Get-EventLog -ComputerName $SMS_000, ...
However, you need to change your filter from
?{$_.EventID -eq 5055 -and $_.Event -eq 6829}
to
?{$_.EventID -eq 5055 -or $_.EventID -eq 6829}
because $_.Event
isn't a valid property and one event can't have 2 different IDs.
Upvotes: 4