Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
  2. $GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object
  3. $GeoWatcher.Start() #Begin resolving current locaton
  4.  
  5. while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {
  6. Start-Sleep -Milliseconds 100 #Wait for discovery.
  7. }
  8.  
  9. if ($GeoWatcher.Permission -eq 'Denied'){
  10. Write-Error 'Access Denied for Location Information'
  11. } else {
  12. $GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement