m1dw0rd

Untitled

Jun 13th, 2022 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location'
  2. $Name         = 'Value'
  3. $Value        = 'Allow'
  4. If (-NOT (Test-Path $RegistryPath)) {
  5.   New-Item -Path $RegistryPath -Force | Out-Null
  6. }
  7. New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType String -Force
  8.  
  9. $RegistryPath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location'
  10. $Name         = 'Value'
  11. $Value        = 'Allow'
  12.  
  13. If (-NOT (Test-Path $RegistryPath)) {
  14.  New-Item -Path $RegistryPath -Force | Out-Null
  15. }
  16. New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType String -Force
  17.  
  18. Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
  19. $GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object
  20. $GeoWatcher.Start() #Begin resolving current locaton
  21.  
  22. while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {
  23.     Start-Sleep -Milliseconds 100 #Wait for discovery.
  24. }  
  25.  
  26. if ($GeoWatcher.Permission -eq 'Denied'){
  27.     Write-Error 'Access Denied for Location Information'
  28. } else {
  29.     $GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
  30. }
Add Comment
Please, Sign In to add comment