Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
- $GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object
- $GeoWatcher.Start() #Begin resolving current locaton
- while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {
- Start-Sleep -Milliseconds 100 #Wait for discovery.
- }
- if ($GeoWatcher.Permission -eq 'Denied'){
- Write-Error 'Access Denied for Location Information'
- } else {
- $GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement