-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrabCoord.ps1
18 lines (15 loc) · 885 Bytes
/
grabCoord.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$scriptblock = {
Set-Itemproperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location' -Name 'Value' -value 'Allow' #sets the current user registry value to allow location access
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 1000 #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.
}
}
Invoke-Command -ComputerName $computer -ScriptBlock $scriptblock