Posted On May 22, 2022

PowerShell: Check a List of Windows Computers for Online & Offline Statuses

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Check a List of Windows Computers for Online & Offline Statuses
# checkOnlineComputers.ps1

# Set a list of computers in a text file
$computerListFile='C:\Temp\computerlist.txt'

# Read the computer list and run SMB tests against each one
$content=get-content $computerListFile
$results=[hashtable]@{}
foreach ($line in $content){
  $smbReach=test-path "\\$($line.trim())\C$\Windows"
  write-host "$line`: $smbReach"
  #pause
  $results+=@{$line=$smbReach}
  }

# Display the results
$results.GetEnumerator() | ?{!$_.value} | %{
    $message = '{0}: {1}' -f $_.key, $_.value
    Write-Output $message
}  

Leave a Reply

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

Related Post

WinRM Issues Caused by Service Principal Name (SPN) HTTP Protocol & Port Associations

Solution as Code: There is no easy solution to this problem. Certain IIS Pool Accounts…

Mods to Zencart

Important Mods to Zencart OC GOLD® setup:   Zens Footer copyright info is moded at…

IIS Server Troubleshooting

Issue: There has been a time when a production IIS server becomes unreachable via RDP,…