Post

Checking Hyper-V server last reboot date

Simple Powershell code to check Hyper-V servers last reboot date if needed. Servers are pulled from their AD OU.

1
2
3
4
5
6
7
8
9
10
11
$OU = "<OUTPUTPATH>"
$Hosts = (Get-ADComputer -Filter * -SearchBase $OU).Name

$array = @()
foreach ($HVHost in $Hosts) {
    $array += [pscustomobject] @{
        "LastReboot" = (Get-CimInstance Win32_OperatingSystem -ComputerName $HVHost).LastBootUpTime
        "Server" = $HVHost
    }
}
$array | Export-CSV <OUTPUTPATH> -NoTypeInformation
This post is licensed under CC BY 4.0 by the author.