Created
October 4, 2018 22:22
-
-
Save ishu3101/d76900d513383595bf5e7c8b8afe78c2 to your computer and use it in GitHub Desktop.
Disable User Access Account (UAC) using PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Disable-UAC(){ | |
$numVersion = (Get-CimInstance Win32_OperatingSystem).Version | |
$numSplit = $numVersion.split(".")[0] | |
if ($numSplit -eq 10) { | |
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value "0" | |
} | |
elseIf ($numSplit -eq 6) { | |
$enumSplit = $numSplit.split(".")[1] | |
if ($enumSplit -eq 1 -or $enumSplit -eq 0) { | |
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" | |
} else { | |
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value "0" | |
} | |
} | |
elseIf ($numSplit -eq 5) { | |
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" | |
} | |
else { | |
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value "0" | |
} | |
Write-Host "Successfully Disabled UAC!" | |
} |
This script makes no sense. UAC was introduced with Windows Vista/Windows Server 2008, i.e. $numSplit -eq 6 -and $enumSplit -eq 0
.
Trying to check and change UAC on $numSplit -eq 5
(Windows 2000 to Windows Server 2003 R2) in line 16 ... 18 is useless...
The only special cases the script handles seems to be for 6.0 and 6.1 where the script sets EnableLUA
to 0.
In all other cases the script changes ConsentPromptBehaviorAdmin
instead...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing.
For Windows 10, I found the registry key values allow you to set different levels from the UAC settings. Here is what I found.
UAC Settings
Control Panel\All Control Panel Items\Security and Maintenance => User Account Control Settings
Registry location:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
The following values on "ConsentPromptBehaviorAdmin" and "PromptOnSecureDesktop" for different levels of UAC settings.