Hi All,
I've been trying to get a Power Shell script to gather a particular event log from a list of remote computers, but as yet not had much success.
The script should query a list of PCs in c:\Scripts\server.txt and gather the "Operational" event log with ID 100 (i'm trying to get the boot up and login times on remote computers)
Script looks like:
$servers=get-content c:\scripts\servers.txt
$date=(Get-Date).AddDays(-7)
foreach ($server in $servers)
{
if (test-connection $server -quiet)
{
$arr1+=get-eventlog -logname Operational -entryType "Warning" -cn $server -after $date | ?{$_.eventid -eq "100" } | select MachineName,EventID,EntryType,Message
}
if ($arr1)
{$arr1 | export-csv c:\scripts\sysoutput.csv -notypeinformation}
else
{"No matching system log events found..."}
}
But keeps returning the "no event logs found". Can anyone point me in the right direction please?
Thanks for any help.
J.