0

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

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .