2020 in the thick of Covid - a client requested a quick (and dirty) way to be able to identify endpoints outside of the UK for contractual purposes. Using Powershell and NinjaRMM it's relatively easy to pull this together in a one liner for reporting back using custom fields ```powershell Invoke-RestMethod -Uri ('http://ipinfo.io/' + (Invoke-WebRequest -UseBasicParsing -Uri 'http://ifconfig.me/ip').Content) | Select-Object ip, hostname, city, region, country, loc, org, postal ``` Alternatively - return an error code and have it trigger an alert on the NinjaRMM dashboard. ```powershell $result = Invoke-RestMethod -Uri ('http://ipinfo.io/' + (Invoke-WebRequest -UseBasicParsing -Uri 'http://ifconfig.me/ip').Content) | Select-Object country Ninja-Property-Set ipgeolocation $result.country if ($result.country = 'GB') { Write-Host '0' exit 0 } else { Write-Host '999' exit 999 } ``` You will need to create a global custom field with the following attributes: ![[Pasted image 20240504234751.png]] Then edit the field to update it to the following settings: ![[Pasted image 20240504234800.png]] You can use this in a script result condition to trigger the built in alerting. --- [[Epistemic status|Colophon: Brewed]]