1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
function Get-UAC { <# .SYNOPSIS Gets the current status of User Account Control (UAC) on a computer, locally or remote. .DESCRIPTION Gets the current status of User Account Control (UAC) on a computer, locally or remote. .AUTHOR Jeff Wouters .NOTES PowerShell 2.0 or higher is required for proper execution of this script. .EXAMPLE Get-UAC .EXAMPLE Get-UAC -ComputerName [ComputerName] .INPUTS N/A. #> [cmdletBinding(SupportsShouldProcess = $true)] param([parameter(ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, Mandatory = $false)][Alias("Computer")][string]$ComputerName) [string]$RegPath = "Software\Microsoft\Windows\CurrentVersion\Policies\System" [string]$RegValue = "EnableLUA" $AccessReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$ComputerName) $Subkey = $AccessReg.OpenSubKey($RegPath,$false) $Subkey.ToString() | Out-Null $UAC = ($Subkey.GetValue($RegValue) -eq 1) if ($UAC -eq 1){ $UACConfig = "Enabled" } elseif ($UAC -eq 0) { $UACConfig = "Disabled" } else {$UACConfig = "Unknown"} return $UACConfig } |
October 12, 2012