在Active Directory CN中运行powershell命令时,一台或多台计算机名称无效

时间:2019-03-21 21:37:01

标签: powershell active-directory

所以我正在学习Powershell,并且当前要在本地内置的管理员帐户中设置密码。我可以在OU测试组中运行以下命令,它可以正常工作。

Invoke-Command -ScriptBlock {net user administrator "R@nd0mP@ssw0rd!@#"} -ComputerName (Get-ADComputer -SearchBase "OU=Test,DC=fqdn,DC=local" -Filter * | Select-Object -Expand Name) *> "C:\users\user\desktop\WinRMAdminPWSet.txt"

如果在包含计算机的CN上运行此命令,则会出现以下错误。

Invoke-Command -ScriptBlock {net user administrator "R@nd0mP@ssw0rd!"} -ComputerName (Get-ADComputer -SearchBase "CN=Computers,DC=fqdn,DC=local" -Filter * | Select-Object -Expand Name) *> "C:\users\user\desktop\WinRMAdminPWSet.txt"

Invoke-Command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI objects instead of strings.
At line:1 char:1
+ Invoke-Command -ScriptBlock {net user administrator "R@nd0mP@ssw0rd! ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException
    + FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand

我觉得在OU和CN上运行此命令应该没有什么区别,但是似乎是这样吗?

0 个答案:

没有答案