Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the urvanov-syntax-highlighter domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in C:\home\site\wwwroot\wp-includes\functions.php on line 6114
Get GeoLocation with PowerShell and set NTP Server in a GPO – A Geeks World

Get GeoLocation with PowerShell and set NTP Server in a GPO

Using Powershell to locate your Geographical Location with the help of GeoLocation (IP-Address) is quite easy, cool and useful!

When we build Private and Hybrid Clouds across the globe in various countries and continents I want to make sure the Active Directory PDC Emulator is using a valid time source based on that location.

GeoLocation with Powershell

So with this small script (it’s using multiple WebServices to cycle through until it gets an answer) we can get a rough location for where we are and in my case it’s usually enough to know what country the datacenter is in.

That can then be used as you see fit. Though for me, I’m using it to update the Group Policy being applied to the PDC Emulator to point to the country specific NTP Pool with the generic pool as backup value.

That’s how easy it’s to modify a Group Policy object.

Please share any solutions using GeoLocation in the comments. It might give me some nice new ideas too!

 

8 thoughts on “Get GeoLocation with PowerShell and set NTP Server in a GPO”

  1. Om du använder denna istället för geoip i scriptet så ser den ut att hantera åäö. MEN den adressen du gav pekar på Timrå, så den databasen kanske inte är helt korrekt?
    Invoke-RestMethod -Method Get -Uri “http://ip-api.com/json/193.12.142.105”

  2. Snyggt. Hur kan jag formatera svaret från freegeoip så att ÅÄÖ visas korrekt? (I mitt fall får jag Jönköping som RegionName.)

Leave a Reply