该成员不存在? Powershell 脚本

The member does not exist? Powershell script

我已经阅读了一些问题并且可以找到有关创建脚本的信息,但 none 似乎使用对象类型 "Computer"。

如果这更适合超级用户,我们深表歉意。但这仍处于脚本级别,因此我认为最好将其放在此处。

这是我的脚本。我想将域注册服务器(计算机)添加到一系列服务器上的性能监视器用户组。

$ComputerName = Read-Host "Remote Computer name:"
$PmuGroup = [ADSI]"WinNT://$ComputerName/Performance Monitor Users,group"
$User = [ADSI]"WinNT://DOMAIN/ServerName,computer"
$PmuGroup.Add($User.Path) 

显示以下错误:

Exception calling "Add" with "1" argument(s): "A member could not be added to 
or removed from the local group because
the member does not exist.
"
At line:1 char:1
+ $AdminGroup.Add($User.Path)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

如果我在 PS 中输入 $user,它 returns 路径似乎找到了机器。

按照评论中的建议在没有 .path 的情况下进行了尝试;

PS C:\WINDOWS> $PmuGroup.Add($User)
Exception calling "Add" with "1" argument(s): "Type mismatch. (Exception 
from HRESULT: 0x80020005
(DISP_E_TYPEMISMATCH))"
At line:1 char:1
+ $PmuGroup.Add($User)
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

这是我脚本的错误吗/任何人都可以就其中的任何错误提出建议吗? 有关信息:Domain/ServerName 不是正在使用的内容。我已经从这里删除了实际名称。

计算机帐户的 samAccountName 总是以 $:

结尾
$ComputerName = Read-Host "Remote Computer name:"
$PmuGroup = [ADSI]"WinNT://$ComputerName/Performance Monitor Users,group"
$Computer = [ADSI]"WinNT://DOMAIN/ServerName$"
$PmuGroup.Add($Computer.Path)