Share via


Ping & LastBootUpTime & UPTIME for multiple computers using Powershell

Ping & LastBootUpTime & UPTIME for multiple computers using Powershell

#Biswajit Biswas 
#MCC, MCSA, MCTS, CCNA, SME
Function Get-ComInfo {   
param(  
## Computers  
$computers
)
$ErrorActionPreference = "SilentlyContinue"
$uptime = Get-CimInstance Win32_OperatingSystem | select LastBootUpTime  
$time = Get-WmiObject -Class Win32_OperatingSystem
$UP = $time.ConvertToDateTime($time.LocalDateTime) – $time.ConvertToDateTime($time.LastBootUpTime)
$status = Test-Connection -ComputerName $computers -count 1 
if ($status.statuscode -eq 0) {
Write-Host "Reachable" $computers "and Bounced"  $uptime.LastBootUpTime  "Uptime" $UP -foregroundcolor white -backgroundcolor DarkGreen
} else {
Write-Host "Not Reachable; Why AM I DEAD"  $computers -foregroundcolor yellow -BackgroundColor Red
}
}
Get-Content c:\computers.txt | ForEach-Object { Get-ComInfo -computers $_} 
Write-Host "I am complete........................................................Happy NEW Year 2014 :)" -foregroundcolor black -backgroundcolor cyan 
Get-Date

Check the Microsoft Technet Gallery-Ping,LastBootUpTime,UPTIME & Last Reboot done by whom for multiple computers. You will get more help.
http://gallery.technet.microsoft.com/scriptcenter/Test-connection-for-d0b462ba