-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpushping.ps1
More file actions
58 lines (45 loc) · 1.38 KB
/
Copy pathpushping.ps1
File metadata and controls
58 lines (45 loc) · 1.38 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
$ip = "."
Function ping-host($ip, $StartingStatus)
{
Do
{
$CurrentStatus = Test-Connection $ip -Count 1 -Quiet
Start-Sleep -Milliseconds 500
echo "$ip $StartingStatus $CurrentStatus"
} while ($StartingStatus -eq $CurrentStatus)
$status = $CurrentStatus
if ($CurrentStatus -eq $true)
{
echo "$ip is responding to pings"
} else {
echo "$ip is not responding to pings"
}
}
Function Send-Pushping
{
param (
[parameter(Mandatory=$true)][string]$message, # Message to be sent to client
[parameter(Mandatory=$false)][string]$title # optional title used by pushover notification
) # end parameters
$user = '[user token]'
$token = '[application token]'
$uri = 'https://api.pushover.net/1/messages.json' # Pushover API address
$parameters = @{ # Parameters to be sent to Pushover service for notification
token = $token
user = $user
title = $title
message = $message
}
$parameters | Invoke-RestMethod -Uri $uri -Method Post | Out-Null # Post rest method used to push $parameters to Pushover; Out-Null to remove all output
}
if ($status -eq $true)
{
echo "$ip is responding to pings"
} else {
echo "$ip is not responding to pings"
}
Do
{
$status = Test-Connection $ip -Count 1 -Quiet
ping-host $ip $status
} while ($true -eq $true)