Showing posts with label Last Boot Up Time. Show all posts
Showing posts with label Last Boot Up Time. Show all posts

Monday, September 12, 2016

Get last boot time from a list

I was asked to reboot 60 some servers just because someone thought they hadn't rebooted in forever.  Being a skeptic I had to verify so I put this thing together from some googleing I did.

First line pulls in a list of machine names.  Second line makes the WMI call then the select.  Last line exports to a CSV.

$ComputerName = Get-Content -Path C:\temp\computers.txt

foreach ($Computer in $ComputerName) { Get-WmiObject win32_operatingsystem -ComputerName $Computer |

       select CSName, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime) } } |
   
              export-csv "C:\temp\Computers_LastBoot_Results.csv" -NoClobber -NoTypeInformation -Append

}