Skip to content

Instantly share code, notes, and snippets.

@mavericksevmont
Created November 6, 2020 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mavericksevmont/de9a2644a7267a16a5c54a3d56fad0ac to your computer and use it in GitHub Desktop.
Save mavericksevmont/de9a2644a7267a16a5c54a3d56fad0ac to your computer and use it in GitHub Desktop.
<#
Ping Machines Script
Draft to use as reference for Homework
#>
$Computers = Get-Content 'C:\Temp\Hosts.txt'
$Output = 'C:\Temp\Results.txt'
$var = foreach ($Computer in $Computers) {
if (Test-Connection -ComputerName $Computer -Count 1 -Quiet) {
Write-Host "$Computer is reachable" -ForegroundColor Green
Write-Output "$Computer is reachable" | Out-File $Output -Append
} else {
Write-Host "$Computer is unreachable" -ForegroundColor Red
Write-Output "$Computer is unreachable" | Out-File $Output -Append
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment