PowerShell Get-Uptime Single and Multiple Computers
In This Video you will be able to learn how to get uptime of multiple remote computer. This script is very easy and you can modify as per your requirement. I am giving the script below. Enjoy !! Script as below ========================================================= $Servers = Get-content "c:\scripts\LivePCs.txt" $LiveServer = @() $DeadServer = @() $currentdate = Get-Date foreach($Server in $Servers){ $pingtest = Test-Connection -ComputerName $Server -Quiet -Count 1 -ErrorAction SilentlyContinue if($pingtest) { $LiveServer += "$Server" } else {$DeadServer += "$Server" }} foreach ($pc in $LiveServer) {$Bootuptime = (Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $pc).LastBootUpTime $uptime = $currentdate - $Bootuptime $up = Write-Output "$($uptime.Days) Days, $($uptime.Hours) Hours, $($uptime.Minutes) Minutes" $Object = [pscustomobject]@{ Computer = $pc Uptime = $up } $Object | Export-Csv -Path "c:\scripts\ServerUptime.csv" -Append -NoTypeInformation } Write-Host "Not Reachable Computer as below" $DeadServer =========================================================
Download
0 formatsNo download links available.