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

Basic CSS: Inherit Styles from the Body Element

<style>body {background-color: black;}</style>

Simple Active Directory & DNS Synchronization Script

@echo offGOTO push_or_pull:push_or_pullset /p action="Type in Push, Pull, or Quit. Press Enter for default action…

PowerShell: Dealing with Service Principle Names (SPNs)

Basic Commands: # Show SPNs$computername="$env:computername"Get-ADComputer -Identity $computername -Properties ServicePrincipalNames |Select-Object -ExpandProperty ServicePrincipalNames# Add one SPNSet-ADComputer…