diff --git a/scripts_wip/Win_Location_Enable.ps1 b/scripts_wip/Win_Location_Enable.ps1 new file mode 100644 index 00000000..5936d454 --- /dev/null +++ b/scripts_wip/Win_Location_Enable.ps1 @@ -0,0 +1,128 @@ +<# +.SYNOPSIS + Enables Location services in Windows + +.DESCRIPTION + Lets you enable/disable device-wide location or User App location + +.PARAMETER Enable + https://www.tenforums.com/tutorials/13225-turn-off-location-services-windows-10-a.html + user = Enable for User App locations + machine = Enable location for system wide + all = Enables both user and machine + +.PARAMETER Disable + https://www.tenforums.com/tutorials/13225-turn-off-location-services-windows-10-a.html + user = Disable for User App locations + machine = Disable location for system wide + all = Disables both user and machine + +.OUTPUTS + Results are printed to the console. + +.EXAMPLE + -Enable machine + +.EXAMPLE + -Disable all + +.NOTES + Change Log + V1.0 Initial release +#> + + +param ( + [string] $Enable, + [string] $Disable +) + + +# HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location +if (Get-PackageProvider -Name NuGet) { + Write-Output "NuGet Already Added" +} +else { + Write-Host "Installing NuGet" + Install-PackageProvider -Name NuGet -Force +} + +if (Get-Module -ListAvailable -Name RunAsUser) { + Write-Output "RunAsUser Already Installed" +} +else { + Write-Output "Installing RunAsUser" + Install-Module -Name RunAsUser -Force +} + +If (!(test-path $env:programdata\TacticalRMM\temp\)) { + New-Item -ItemType Directory -Force -Path $env:programdata\TacticalRMM\temp\ +} + +If (!(test-path $env:programdata\TacticalRMM\temp\curpsxpolicy.txt)) { + $curexpolicy = Get-ExecutionPolicy + + ( + Write-Output $curexpolicy + )>$env:programdata\TacticalRMM\temp\curpsxpolicy.txt +} +Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell -Name ExecutionPolicy -Value Unrestricted + +if (!$Enable -AND !$Disable) { + Write-Host "At least one parameter is required: Enable or Disable." + Exit 1 +} + +# Used to pull variables in and use them inside the script block. Contains message to show user +Set-Content -Path c:\temp\message.txt -Value $args + +Invoke-AsCurrentUser -scriptblock { + Write-Output "Runasuser started" | Out-File -append -FilePath c:\temp\raulog.txt + $Enable = Get-Content -Path c:\temp\message.txt + Write-Output $Enable | Out-File -append -FilePath c:\temp\raulog.txt + Write-Output "$Enable" | Out-File -append -FilePath c:\temp\raulog.txt + Write-Output "Debug output finished" | Out-File -append -FilePath c:\temp\raulog.txt + + if ($Enable -eq "user" -or $Enable -eq "all") { + # https://www.tenforums.com/tutorials/13225-turn-off-location-services-windows-10-a.html + $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" + $Name = "Value" + $value = "Allow" + New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null + Write-Output "Enabled Location for user" | Out-File -append -FilePath c:\temp\raulog.txt + } + elseif ($Disable -eq "user" -or $Disable -eq "all") { + $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" + $Name = "Value" + $value = "Deny" + New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null + Write-Output "Disabled Location for user" | Out-File -append -FilePath c:\temp\raulog.txt + } + +} + +$exitcode = Get-Content -Path "c:\temp\raulog.txt" +Write-Host $exitcode + + +$curpsxpol = Get-Content -Path $env:programdata\TacticalRMM\temp\curpsxpolicy.txt; +Set-ExecutionPolicy -ExecutionPolicy $curpsxpol + +if ($Enable -eq "machine" -or $Enable -eq "all") { + # https://www.tenforums.com/tutorials/13225-turn-off-location-services-windows-10-a.html + $registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" + $Name = "Value" + $value = "Allow" + New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null + Write-Output "Enabled Location for machine" +} + +if ($Disable -eq "machine" -or $Disable -eq "all") { + $registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" + $Name = "Value" + $value = "Deny" + New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null + Write-Output "Disabled Location for machine" +} + +Remove-Item -path "c:\temp\raulog.txt" \ No newline at end of file diff --git a/scripts_wip/Win_Location_Get.ps1 b/scripts_wip/Win_Location_Get.ps1 new file mode 100644 index 00000000..a35e0e37 --- /dev/null +++ b/scripts_wip/Win_Location_Get.ps1 @@ -0,0 +1,16 @@ +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. + $a = $GeoWatcher.Position.Location + write-host "$a" +} \ No newline at end of file diff --git a/scripts_wip/Win_TaskScheduler_Edit.ps1 b/scripts_wip/Win_Location_Task_Trigger_On_WLAN_event.ps1 similarity index 100% rename from scripts_wip/Win_TaskScheduler_Edit.ps1 rename to scripts_wip/Win_Location_Task_Trigger_On_WLAN_event.ps1 diff --git a/scripts_wip/Win_TRMM_Remove_and_Reinstall.ps1 b/scripts_wip/Win_TRMM_Remove_and_unjoin_from_AzureAD.ps1 similarity index 92% rename from scripts_wip/Win_TRMM_Remove_and_Reinstall.ps1 rename to scripts_wip/Win_TRMM_Remove_and_unjoin_from_AzureAD.ps1 index 52f5b515..ab63292f 100644 --- a/scripts_wip/Win_TRMM_Remove_and_Reinstall.ps1 +++ b/scripts_wip/Win_TRMM_Remove_and_unjoin_from_AzureAD.ps1 @@ -1,4 +1,5 @@ # gretsky https://discord.com/channels/736478043522072608/744281869499105290/890996626716508180 +# remove non domain joined device from trmm and unjoin them from Azure Ad $domain = (Get-WmiObject -Class win32_computersystem -ComputerName localhost).domain if ($domain.toupper().contains('DOMAIN')) {