Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

check user account control setting for multiple servers

$
0
0
$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?

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>