Created
November 6, 2020 22:27
-
-
Save mavericksevmont/de9a2644a7267a16a5c54a3d56fad0ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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