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

PowerShell: Add Accounts into Local Administrators Group

# addAccountToLocalAdmins.ps1# Requires: PowerShell Version 4.0+$accountToAdd='ServerAdmins'$groupName="Administrators"$servers=@( "CONCU1", 'CONCU2', 'CONCU100', 'CONCU80665', 'CONCU6547354', 'CONWHAT989', 'CONCU3')$servers|%{ $session=new-pssession $_…

PowerShell: Microsoft Clustered Disks Creation Script v 0.10

Code: <# Microsoft_Clustered_Disks_Creation_V0.10.ps1Purpose:This snippet streamlines the process of creating physical disk volumes on a Windows…

Basic HTML and HTML5: Create a Bulleted Unordered List

<h2>CatPhotoApp</h2><main><p>Click here to view more <a href="#">cat photos</a>.</p><a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying…