Script to check last reboot date-time with credentials used to reboot

Please help to share power shell  script To check last reboot for windows servers (mentioned in server list ) with user id used for reboot
patronTechnical consultant Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yo_beeDirector of Information TechnologyCommented:
You will need the Active Directory Module on the computer you want to run this script from.
I have a Get-WinEvent script that I use to see how long a user's computer is locked and I figure I can do something similar for your request.

I first gather all the computer in my environment using the Get-ADComputer  and then for each computer I run Get-WinEvent and story it in an array.

$computers = Get-adcomputer -Filter * -SearchBase 'OU=Computers,OU=FLH,DC=contoso,DC=com' -SearchScope OneLevel 
$Table = @()
Foreach ($computer in $computers)
 If(Test-Connection -ComputerName $
    Get-WinEvent -ComputerName $computer.Name -FilterHashtable @{ProviderName='User32';ID = 1074} | select -First 1 | foreach {  $sid = $_.userid;  if($sid -eq $null) { return; }  $objSID = New-Object System.Security.Principal.SecurityIdentifier($sid);  $objUser = $objSID.Translate([System.Security.Principal.NTAccount]);
     $Results = New-Object Object
     $Results | Add-Member -Type NoteProperty -Name 'Computername' -Value $ 
     $Results | Add-Member -Type NoteProperty -Name 'User' -Value $objUser.Value
     $Results | Add-Member -Type NoteProperty -Name 'Date' -Value $_.TimeCreated
     $table += $Results
    $table | Export-Csv -Path C:\temp\Lastreboot.csv -NoTypeInformation

Open in new window

I took some info from these two sites and put together the script.
Jess DodsonWindows System AdministratorCommented:
I wrote up a post on how to set this up:

Includes all the .xml files etc, that you'll need for it all which are all up on GitHub.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
patronTechnical consultant Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.