Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created March 17, 2016 13:16
Show Gist options
  • Save PrateekKumarSingh/5b79f80a38f23e090673 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/5b79f80a38f23e090673 to your computer and use it in GitHub Desktop.
Function Get-LastBootTime($servers)
{
$creds = Get-Credential 'domain\username'
$lastbootuptime=@()
foreach($s in $servers)
{
$Wmio=Get-WmiObject win32_operatingsystem -ComputerName $S -Credential $creds
$Last = $wmio.converttodatetime($wmio.lastbootuptime)
$lastbootuptime+= New-Object psobject -Property @{ Servername= $s
LastRebootDate=$last.tostring("dd-MM-yyyy")
}
}
Return $lastbootuptime
}
Get-LastBootTime $(gc D:\servers.txt) | ft -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment