Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

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.