I need script which can take the remote machine names from a text file as input and return the particular event ID status of all the servers. System event ID 19.
-
Friday, March 02, 2012 7:07 AMI need script which can take the remote machine names from a text file as input and return the particular event ID status of all the servers. System event ID 19.
All Replies
-
Friday, March 02, 2012 7:28 AM
get-eventlog -computername "hostname" -log application -source outlook | where {$_.eventID -eq 34}
Get-EventLog cmdlet can query remote macines for specific eventid, sources and data ranges.
To get all computers from a text file and query events;
Get-Content c:\names.txt | ForEach-Object {get-eventlog -computername "hostname" -log application -source outlook | where {$_.eventID -eq 34}}
- Proposed As Answer by Anil_Erduran Friday, March 02, 2012 11:51 AM
- Marked As Answer by Rick TanModerator Monday, March 12, 2012 3:20 AM
-
Monday, March 05, 2012 3:15 AMModerator
Hi,
Thank you for the post.
You could also use Get-EventsByWmi.ps1 script to achieve it.
Get-EventsByWmi.ps1 -computer c:\myservers.txt -log system -eventid 19If there are more inquiries on this issue, please feel free to let us know.
Regards
Rick Tan
TechNet Community Support
- Marked As Answer by Rick TanModerator Monday, March 12, 2012 3:20 AM
-
Saturday, May 19, 2012 11:34 AM
Hi...getting below error.
PS C:\> C:\Users\gchand-admin\Desktop\Get-EventsByWmi.ps1 -computer c:\Servers.t
xt -log system -eventid 19
Querying system Log for EventID: 19
Get-WmiObject : Invalid parameter
At C:\Users\gchand-admin\Desktop\Get-EventsByWmi.ps1:22 char:15
+ Get-WmiObject <<<< -Class win32_NTLogEvent -filter "logfile = '$log' and Ev
entCode = '$eventID'" -computerName $computerName
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
tException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
ommands.GetWmiObjectCommandCompleted querying c:\Servers.txt.length computers
PS C:\>

