kjacobsen icon

Why you reboot?

kjacobsen | PRO | 04/02/12 09:20:06 AM UTC | 0 ⭐ | 276 👁️ | Never ⏰ | []
PowerShell |

750 B

|

None

|

0 👍

/

0 👎

# Code Snippet from aperturescience.su
# Parameters
 
# Body
 
$emailbody = "The server has just been restarted. Relevant Windows Event log entries:`n"
$emailbody += "------------------------------------------------------------------------`n"
 
$entries = Get-WinEvent -logname system -MaxEvents 5000 -ErrorAction SilentlyContinue | Where-Object {((($_.id -eq 12) -or ($_.id -eq 13)) -and ($_.providername -eq "Microsoft-Windows-Kernel-General")) -or ($_.providername -eq "USER32") -or (($_.providername -eq "Microsoft-Windows-Kernel-Power") -and ($_.id -eq 41))}
 
 
foreach ($entry in $entries)
{
    $emailbody += $entry.timecreated
    $emailbody += $entry.Message
    $emailbody +="`n"
}
 
send-email $emailbody $true
 
# Code Snippet from aperturescience.su

Comments