Created
March 17, 2016 13:16
-
-
Save PrateekKumarSingh/5b79f80a38f23e090673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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