forked from limeman38/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpingServer.ps1
39 lines (34 loc) · 1.14 KB
/
pingServer.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
################################################################
##
## pingServer.ps1
## Created By : Nick Clark
## Owner : Nick Clark
## Date : March 2018
##
## Copyright © 2018 Nick Clark
## This software is proprietarily created and maintained by Nick Clark for its sole use.
## You may NOT redistribute copies of this code.
## There is NO WARRANTY, to the extent permitted by law.
##
################################################################
function pingServer($filePath)
{
if (!$filePath)
{
Write-Host "You need to enter filepath for servers to check"
} #end if
$fileContents = Get-Content $filePath
foreach ($computer in $fileContents)
{
if (Test-Connection -ComputerName $computer -Count 1 -ErrorAction SilentlyContinue)
{
$host.ui.RawUI.ForegroundColor = "Green"
Write-Host "$computer, UP"
}
else
{
$host.ui.RawUI.ForegroundColor = "Red"
Write-Host "$computer, DOWN"
}
} #end for loop
} #end function pingServer