如何从本地管理员组中删除 NT AUTHORITY\Authenticated Users (S-1-5-11)?我尝试了 2 个脚本,发现有各种用户提供,但出现以下错误:
脚本#1:
[ADSI]$power="WinNT://computername/Administrators,group"
$power.Remove($NT AUTHORITY\Authenticated Users (S-1-5-11))
错误 #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
脚本#2:
$group = [ADSI]("WinNT://"+$env:computername+"/administrators,group")
$group.remove("WinNT://$env:computername/NT AUTHORITY\Authenticated Users (S-1-5-11),user")
错误 #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
我不是确切地确定脚本 2 为什么会抛出该错误,但是这似乎是一种混乱的编写方式。
尝试这个:
$comp = $env:COMPUTERNAME
$admingroup = [ADSI]("WinNT://$comp/administrators,group")
$admingroup.remove("WinNT://NT Authority/Authenticated Users")
请注意线条的差异.remove
。