Powershell与活动目录的远程处理

我能够通过下面的脚本远程连接到域控制器,但之后,我想运行disable-ADAccountGet-ADUser命令,但我得到错误

 Get-ADUser : The server has rejected the client credentials. 

如何在单个脚本文件中调用活动目录命令?

 $password = ConvertTo-SecureString "Password" -AsPlainText -Force $cred= New-Object System.Management.Automation.PSCredential ("Lab\dcadmin", $password) Enter-PSSession -ComputerName dc-01 -Port 5985 -Credential $cred 

试试这个:在join到相关域的计算机上,右键单击Powershell开始菜单图标或快捷方式,然后select“以pipe理员身份运行”。 input域pipe理员帐户的凭据。 然后尝试Powershell命令。 他们应该在域pipe理员帐户的情况下运行,你应该没有授权问题。

请注意,如果您使用本地pipe理员帐户loginjoin域的计算机,则可能无法使用,因为当您select“以pipe理员身份运行”时,它将以本地pipe理员身份运行,而不会提示input凭据。 以不是pipe理员或域pipe理员的用户身份login到计算机。