kkpareek
kkpareek

Reputation: 530

Is there an easy and direct way to to check whether UAC is enabled/disabled in windows?

I'm using the following command for getting the enabled status:

REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA

The output of above command in case UAC is enabled is as:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
    EnableLUA    REG_DWORD    0x1

And the output in case UAC is disabled remains as:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
    EnableLUA    REG_DWORD    0x0

The difference is 0x0 and 0x1

For checking the similar status for a service, I'm using: (get-service service-name).status command.

It gives me output as a single string only as: Stopped/Running/Disabled

Looking for a similar approach for knowing UAC status.

Upvotes: 0

Views: 938

Answers (1)

Theo
Theo

Reputation: 61178

Perhaps you mean something like this?

$uac = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'EnableLUA' -ErrorAction SilentlyContinue
if ($null -eq $uac) { 'NotConfigured' }
elseif ($uac -eq 0) { 'Disabled' }
else { 'Enabled' }

Upvotes: 2

Related Questions