Powershell Function to Get the Last Boot Up Time of a Computer

[sourcecode language=”powershell” wraplines=”false”]
#Return the last reboot time of a computer
#Usage: Get-LastBootUpTime [ServerName]
Function Get-LastBootUpTime
{
param ([string]$computername=$env:computername)
$computername = $computername.toupper()
Get-WmiObject -ComputerName $computername win32_operatingsystem| select csname, @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
}
[/sourcecode]


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *