# Check Public IP-script # $CurrentIP = "xx.xx.xx.xx" $apikey = "xx" $credentials = New-Object System.Management.Automation.PSCredential ($apiKey, (ConvertTo-SecureString $apiKey -AsPlainText -Force)) $ifconfig = Invoke-WebRequest ifconfig.co/json | ConvertFrom-Json if ($ifconfig.IP -ne $CurrentIP) { 'new ip!' $pushDevices = Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/devices' -Method Get -Credential $credentials foreach ($device in $pushDevices.devices) { # build the notification $notification = @{ device_iden = $device.iden type = 'note' title = 'IP Address Change detected' body = "New IP address $($ifconfig.ip) is detected" } Invoke-RestMethod -Uri 'https://api.pushbullet.com/api/pushes' -Body $notification -Method Post -Credential $credentials } }