Skip to content

Instantly share code, notes, and snippets.

@poiriersimon
Last active January 9, 2019 15:36
Show Gist options
  • Save poiriersimon/b0dc23fc885ea2879267757286d0ffa9 to your computer and use it in GitHub Desktop.
Save poiriersimon/b0dc23fc885ea2879267757286d0ffa9 to your computer and use it in GitHub Desktop.
Test if Exchange Online IP are resolving to the same country as your machine
$CollectorIp = Invoke-RestMethod -Uri 'http://ipinfo.io'
$DNSName = Resolve-DnsName "outlook.office365.com.g.office365.com"
$EXOIpsLocation = $(foreach($ip in $DNSName.ip4Address){Invoke-RestMethod -Uri "http://ipinfo.io/$($Ip)"}) |select -expandproperty Country -Unique
if($EXOIpsLocation -contains $CollectorIp.Country){Write-host "Ok"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment