enter-pssession:连接到远程服务器失败,并显示以下错误消息:用户名或密码不正确

我无法通过下面的脚本连接到域控制器。 此脚本正在为另一个域控制器工作,所以它意味着脚本是正确的。 当我连接时,我得到一个错误:

enter-pssession : Connecting to remote server "COMPUTER Name" failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic. 

我100%确定我的凭据是正确的,如果我手动键入,我可以连接(PSsession)到域。

脚本 –

 $password = ConvertTo-SecureString "<MyPassword>" -AsPlainText -Force $cred= New-Object System.Management.Automation.PSCredential ("<Domain\UserName>", $password) Enter-PSSession -ComputerName <IPAddress> -Port <PortNumber> -Credential $cred 

WinRM服务正在工作。 Set-Item WSMan:\localhost\Client\TrustedHosts *也被应用。