How to Automatically Update My PowerShell Script with GPS Data for "Which County Am I In Right Now

I’ve been using PowerShell for various automation tasks, and recently I came across an interesting challenge. I often find myself needing to know my current county for various reasons, such as when I’m traveling or working in different locations. I discovered an online tool called “which county am i in right now” that provides this information based on GPS data.

I’m curious if there’s a way to automate the process of retrieving this county information using PowerShell. Specifically, I’m looking to write a script that can automatically fetch my current county by leveraging GPS data from my device or perhaps by querying an API provided by the tool. Once I have this information, I would like to store it in a variable that I can use for further actions within my PowerShell script, such as logging the location data, sending notifications, or even automating tasks based on my current county.

However, I’m unsure how to begin with integrating GPS data retrieval into PowerShell. What’s the best approach to get this kind of information? Are there any existing cmdlets or modules that could help in accessing GPS data on Windows, or would I need to rely on external APIs? If using an API is the best route, how would I authenticate and make the appropriate calls within PowerShell?

Additionally, I’m concerned about the accuracy of the data, especially when moving between locations. How often should the script poll for updates, and what would be the best way to handle cases where GPS data might be unavailable or inaccurate?

I’m also considering the potential security implications of regularly accessing GPS data. How should I manage and protect this sensitive information within my PowerShell script to ensure it’s only accessible by authorized users or processes?

I’d appreciate any advice or examples from those who have tackled similar challenges or have experience working with GPS data in PowerShell. Any pointers on efficient methods, potential pitfalls, or even alternative approaches would be highly valuable.

Dragoslav,
Welcome to the forum. :wave:t3:

In general … This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

Where do the GPS data come from? Do you have GPS capable hardware build in your Windows pc?

Anywhere you want. :wink: … just start anywhere. :+1:t3:

Have you tried to search for it yourself?

Are there external APIs you know of?

That depends on the API I’d say.

What are your concerns?

That depends on your expectations or the pupose the script you’re planing to write is for.

Again … that depends on you or your expectations or requirements to the script. :man_shrugging:t3:

I’ve written some stuff already for getting GPS coordinates out of your computer via PowerShell.
Get-GeoLocation
Once you’ve got the GPS coordinates there are quite a few APIs out there you can feed them to and get location data in return.

I played with your code and was surprised at how close/accurate the coordinates were since I am on a corporate system with all sorts of complicated networking. Very interesting. Thanks for sharing.