Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I remove the NT AUTHORITY\Authenticated Users (S-1-5-11) from the local administrator group? I tried 2 scripts I found that various users provided, but I get the errors below:

Script #1:

[ADSI]$power="WinNT://computername/Administrators,group"
$power.Remove($NT AUTHORITY\Authenticated Users (S-1-5-11))

Error #1:

Missing ')' in method call.
At C:\Users\<myusername>\AppData\Local\Temp\31f87d11-3558-42dd-b62f-b4e21ab74056.ps1:2 char:19
+ $power.Remove($NT  <<<< AUTHORITY\Authenticated Users)
    + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], ParseException
    + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

Script #2:

$group = [ADSI]("WinNT://"+$env:computername+"/administrators,group")
$group.remove("WinNT://$env:computername/NT AUTHORITY\Authenticated Users (S-1-5-11),user")

Error #2:

You must provide a value expression on the right-hand side of the '-' operator.
At C:\Users\<myusername>\AppData\Local\Temp\31f87d11-3558-42dd-b62f-b4e21ab74056.ps1:2 char:41
+ $group = [ADSI]("WinNT://"+$env:50NV9S1- <<<< E6520+"/administrators,group")
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : ExpectedValueExpression
share|improve this question

I'm not exactly sure why script 2 is throwing that error, but it seems like a messy way to write it.

Try this:

$comp = $env:COMPUTERNAME
$admingroup = [ADSI]("WinNT://$comp/administrators,group")
$admingroup.remove("WinNT://NT Authority/Authenticated Users")

Note the difference in the .remove line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.