$servers="DEN-DC-01", "DEN-GW-01", "DEN-SRV-01","DEN-SRV-02","FTC-CL1-01" Function get-UserAccountControl ($server) { [string]$RegPath = "Software\Microsoft\Windows\CurrentVersion\Policies\System" [string]$RegValue = "EnableLUA" $OpenRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$server) $subKey = $OpenRegistry.OpenSubKey($RegPath,$false) $UAC = ($Subkey.GetValue($RegValue) -eq 1) if ($uac -eq 1 ) { return( " uac is enabled") } else { return (" uac is disabled") } } foreach ($srv in $servers) { write-host "The server is $srv" $useraccount= get-UserAccountControl($srv) write-output $useraccount }
When i run the above script, i get the UAC control enables for all the servers though it is disabled in most of the server.
Can someone help?