Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell script for gathering specific events ids for multiple computers

$
0
0

Hi Guys,

I am trying to work on a powershell script in which we need to gather specific event ids for reboots across muliple computers in our organziation.

The script works fine providing expected output but there is 1 glitch.While running if there is any server which is either powered down or user account doesnot have permission the script terminates without providing any output.

COuld someone help with the script so that if i try to run it for muliple computer and on any errors if server is found dead or unreachable or acceedenied ,script can ignore those server and move on to next ..The servers with issues can moved to a diff file errors_Server.txt

Also,since this script would run across 500 servers so would be helpful if somehow the run time is reduced.

Script layout:

$logPath = "C:\amigo"
$log = "System"
$computers = Get-Content c:\amigo\servers.txt 
# Start HTML Output file style
$style = "<style>"
$style = $style + "Body{background-color:white;font-family:Arial;font-size:6pt;}"
$style = $style + "Table{border-width: 1px; border-style: solid; border-color: blue; border-collapse: collapse;}"
$style = $style + "TH{border-width: 1px; padding: 2px; border-style: solid; border-color: black; background-color: #cccccc;}"
$style = $style + "TD{border-width: 1px; padding: 5px; border-style: solid; border-color: black; background-color: white;}"
$style = $style + "</style>"
# End HTML Output file style
$Date=(Get-Date).AddDays(-31)
$systemErrors = Get-EventLog -Computername $computers -LogName $log -EntryType ("Information") -after $date | ?{$_.eventid -eq "6005" -or $_.eventid -eq "6006" -or $_.eventid -eq "1074"} | select EventID,MachineName,Message,Source,TimeGenerated
$systemErrors | ConvertTo-HTML -head $style | Out-File "$logPath\Server-Reboot.htm"


ManeeshB



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>