Last active
January 9, 2019 15:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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