So your boss is yelling at you about OS patches, or more specifically, the lack of application of said patches. What's new? Your boss is always yelling at you; this time it happens to be about patches. Last time the boss was yelling at you it was probably something you screwed up, this time the yelling is about something you haven't screwed up yet.
So, as the worst admin ever, what do you do? You find a couple old servers to patch to get the heat off your back so you can get back to watching the Woot-off.
So how do you find a few old servers? Your memory of host names and hardware is sub-goldfish level, not to mention your dyslexia, so don't even try to ballpark this one. Fire up Hyena, pump all your servers out to a .csv file, then fire up this little gem to find out who hasn't been rebooted for a while. Start up the incredibly fast software update process, then get back to the Woot-off.
##Blank out previous log file
out-file serveruptime.txt
import-csv Servers.csv | foreach {
$server = $_.server
##Check for LastBootupTime
$Uptime = (get-wmiobject win32_operatingsystem -computername $server).lastbootuptime
if ($Uptime -gt 0)
{
$Year = ($Uptime).substring(0,4)
$Month = ($Uptime).substring(4,2)
$Day = ($Uptime).substring(6,2)
"$Server,$Month/$Day/$Year" | out-file serveruptime.txt -append
}
else
{
"$Server,WMI Failure" | out-file serveruptime.txt -append
}
}