Powershell - Get system uptime
$Computer = Read-Host "Input Computer Name "
$LastBoot = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer ).LastBootUpTime
$uptime = (Get-Date) - [System.Management.ManagementDateTimeconverter]::ToDateTime($LastBoot)
Write-Host "$Computer uptime is:" [$uptime] [dd:hh:mm:ss.ms]
$LastBoot = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer ).LastBootUpTime
$uptime = (Get-Date) - [System.Management.ManagementDateTimeconverter]::ToDateTime($LastBoot)
Write-Host "$Computer uptime is:" [$uptime] [dd:hh:mm:ss.ms]
Comments
Post a Comment