tacticalrmm/scripts/Win_UAC_Check_Status.ps1

22 lines
560 B
PowerShell
Raw Normal View History

2021-04-10 17:44:02 +00:00
$ErrorActionPreference = 'silentlycontinue'
$PSDenabled = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System).PromptOnSecureDesktop
$CPAenabled = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System).ConsentPromptBehaviorAdmin
if ($PSDenabled -Eq 1 -And $CPAenabled -Eq 5) {
Write-Output "UAC is Enabled"
exit 0
}
elseif ($PSDenabled -Eq 1 -And $CPAenabled -Eq 2) {
Write-Output "UAC is Enabled"
exit 0
}
else {
Write-Output "UAC is Disabled"
exit 1
}
Exit $LASTEXITCODE