当我user以与服务器相同的身份登录时,我可以Enter-PSSession:
> Enter-PSSession -ConnectionURI http://xxx.xx.xxx.xx:5985
Run Code Online (Sandbox Code Playgroud)
但是,当我以不同的用户身份(在同一台机器上)登录并尝试Enter-PSSession使用-Credential参数时:
> Enter-PSSession -ConnectionUri http://xxx.xx.xxx.xx:5985 -Credential user
Run Code Online (Sandbox Code Playgroud)
输入密码后,我得到:
Enter-PSSession : Connecting to remote server xxx.xx.xxx.xx failed with the
following error message : Access is denied. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ConnectionUri http://xxx.xx.xxx.xx:5985 -Credential user
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (http://xxx.xx.xxx.xx:5985/:Uri
) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Run Code Online (Sandbox Code Playgroud)
(1) 如果您使用的是默认的 WinRM 配置,则可以跳过 http:// 内容,而不是:
输入以下内容:
Enter-PSSession xxx.xx.xx.xx
如果系统有 DNS 条目,您还可以使用服务器的 DNS 名称而不是其 IP。
(2) 默认情况下,只允许管理员组的成员连接到 PS 远程端点。您确定您的帐户是该组的成员吗?
(3) 我在某处读到 Enter-PSSession 的 -Credential 参数已损坏。解决方法是预先创建凭证对象:
$cred = 获取凭证
输入-PSSession XXX.XX.XX.XX -credential $cred
请尝试并报告它是否有效。
(4) 如果您尝试连接到不属于您的域的计算机,则需要将其添加到您尝试从以下位置启动远程会话的计算机上的受信任计算机列表中:
winrm s winrm/config/client '@{TrustedHosts="RemoteComputerName"}'
并且您需要明确告诉 enter-pssession 将使用远程计算机上的哪个用户帐户:
$Cred = Get-Credential "远程计算机名\用户名"
Enter-PSSession XXX.XX.XX.XX -Credential $Cred
| 归档时间: |
|
| 查看次数: |
14032 次 |
| 最近记录: |