为了使其发挥作用,您必须配置本地和远程计算机。
在远程服务器上,运行以下命令:
Enable-WSManCredSSP -Role server
你会知道,如果你运行Get-WSManCredSSP
cmdlet的事情正确confgured并得到下面的输出:
The machine is not configured to allow delegating fresh credentials. This computer is configured to receive credentials from a remote client computer.
在本地计算机上,从管理PowerShell提示符处,您需要允许在PowerShell中进行凭据委托。运行以下命令:
Enable-WSManCredSSP -Role Client -DelegateComputer <REMOTE_COMPUTER_NAME>
您可以通过使用*为REMOTE_COMPUTER_NAME
使所有服务器。
The machine is configured to allow delegating fresh credentials to the following target(s): wsman/REMOTE_SERVER_NAME
This computer is not configured to receive credentials from a remote client computer.
在本地计算机,更新组策略,让您的凭据委托给:
你会知道这个,当你运行Get-WSManCredSSP并得到下面的输出配置正确远程服务器。
- 打开gpedit.msc并浏览到Computer Configuration> Administrative Templates> System> Credentials Delegation。
- 双击“允许使用仅限NTLM的服务器身份验证委托新凭据”。
- 启用设置并将生成服务器添加到WSMAN/BuildServerName的服务器列表中。 (您可以通过输入WSMAN/*启用所有服务器。)
然后,当你需要在远程服务器上运行命令,你不能使用任何的* -PSSession的命令因为能的CredSSP不使用缓存的凭据。你必须开始使用Invoke-Command
的会话,使用的CredSSP作为值的验证参数,像这样:
Invoke-Command -ScriptBlock { # remote commands here } `
-ComputerName <REMOTE_COMPUTER_NAME> `
-Authentication CredSSP `
-Credential <USERNAME>
在dos shell命令'dir \\ server \ share \ folder'中没有提示错误? –
这是正确的。也许我应该写“dir \\ MyServer \ MyShare \ MyFolder”。我确实发现我需要设置CredSSP,我做了,但仍然收到一个超时值,然后是Enable-WSManCredSSP:由于无法启用该设置,因此无法执行此命令。如果没有网络连接,就会发生这种情况。 –
现在,我使用gpedit.msc来允许在这两台计算机上使用新的证书。我设置了新的证书策略,并使用'enable-wsmancredssp -role client -delegatecomputer computer1.domain.com'和'enable-wsmancredssp -role server'命令。对于状态,我执行'Get-WSManCredSSP',我得到 **机器配置为允许将新的凭据委托给以下目标:wsman/computer1.domain.com,wsm 和/ *。domain.com。这台计算机被配置为从远程客户端计算机接收凭证。**我找不到其他任何人要执行的操作,但它仍然无法运行! –