locked
check user account control setting for multiple servers RRS feed

  • Question

  • $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?
    Thursday, May 23, 2013 10:08 AM

Answers

  • I ran your code exactly as pasted and it is returning the correct results for the two servers (Server 2012 and Server 2008 x86) and laptop (Win7 Pro x64) I ran it against. I tried with V2 and V3 and there was no difference.

    Looks like the forum is still having intermittent issues. This post was made by me, but I bet it'll show up as being posted by MigrationUser1...

    • Edited by Mike Laughlin Friday, May 24, 2013 3:44 AM
    • Marked as answer by Yan Li_ Friday, June 7, 2013 2:54 AM
    Friday, May 24, 2013 3:27 AM

All replies

  • Hi,

    please give us a litle bit more informations. ;-)

    In which powershell are you executing the script (64bit / 32bit)? On which Server OS (Version + 64/32bit) are the Servers running?

    Greetings Malte

    Thursday, May 23, 2013 11:46 AM
  • I ran your code exactly as pasted and it is returning the correct results for the two servers (Server 2012 and Server 2008 x86) and laptop (Win7 Pro x64) I ran it against. I tried with V2 and V3 and there was no difference.

    Looks like the forum is still having intermittent issues. This post was made by me, but I bet it'll show up as being posted by MigrationUser1...

    • Edited by Mike Laughlin Friday, May 24, 2013 3:44 AM
    • Marked as answer by Yan Li_ Friday, June 7, 2013 2:54 AM
    Friday, May 24, 2013 3:27 AM