Single Server Reboot Report:


Get-WinEvent -FilterHashtable @{logname='System'; id=1074}  | ForEach-Object {
$rv = New-Object PSObject | Select-Object Date, User, Action, Process, Reason, ReasonCode, Comment
$rv.Date = $_.TimeCreated
$rv.User = $_.Properties[6].Value
$rv.Process = $_.Properties[0].Value
$rv.Action = $_.Properties[4].Value
$rv.Reason = $_.Properties[2].Value
$rv.ReasonCode = $_.Properties[3].Value
$rv.Comment = $_.Properties[5].Value
$rv
} | Select-Object Date, Action, Reason, User





Multiple Servers Reboot Report:


001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028

Function Get-ComInfo {
param(
## Computers
$computers
)
 
"#"*160
"Server Reboot Report"
"Generated $(get-date)"
"Generated from $(gc env:computername)"
"#"*160
 
Get-WinEvent -ComputerName $computers -FilterHashtable @{logname='System'; id=1074}  |
ForEach-Object {
$rv = New-Object PSObject | Select-Object Date, User, Action, Process, Reason, ReasonCode, Comment
$rv.Date = $_.TimeCreated
$rv.User = $_.Properties[6].Value
$rv.Process = $_.Properties[0].Value
$rv.Action = $_.Properties[4].Value
$rv.Reason = $_.Properties[2].Value
$rv.ReasonCode = $_.Properties[3].Value
$rv.Comment = $_.Properties[5].Value
$rv
} | Select-Object Date, Action, Reason, User
}
Get-Content computers.txt | ForEach-Object { Get-ComInfo -computers $_}

Required powershell 3 & higher.
Function Get-ComInfo { 
   
param( 
## Computers 
$computers 
   
   
"#"*80 
"Server LastBootUpTime-InstallDate-Sl Nos Report" 
"Generated $(get-date)" 
"Generated from $(gc env:computername)" 
"#"*80 
   
Get-CimInstance Win32_OperatingSystem -comp $computers | select  csname,LastBootUpTime
   
   
Get-Content computers.txt | ForEach-Object { Get-ComInfo -computers $_} | 
Out-File -Append Servers_LastBootUpTime.txt

_____________________________________________________________________________________________________________

Regards
Biswajit Biswas
My Blogs|TechnetWiki Ninja