在远程CredSSP呼叫中启动作业时出现问题

时间:2011-09-01 17:02:21

标签: powershell powershell-v2.0 credentials background-process powershell-remoting

所以从机器X我连接到Y,Creds A作为CredSSP,然后我通过Cred B,我想在机器Y上用Cred B开始工作。

虽然我可以将RDP作为X进入机器Y,并在本地成功创建作为Y的作业,当我使用远程处理时。我收到一个错误。这里是按

问题复制的示例代码
$sb1 = {param($cred) $cred ; write-host "started"  ; start-job  -Credential $cred -ScriptBlock {"yo"} | Wait-Job | Receive-Job }
$j = invoke-command -ComputerName $compy -Credential $creda -Authentication CredSSP -ScriptBlock $sb1 -argumentlist $credb

它在接收作业上的错误,在30秒之后或某事(可能是一些超时)并且我没有看到在任务管理器中创建的任何进程 (当我在脚本块中用“yo”睡觉时)。

这是回来的错误

[localhost] The background process reported an error with the following message: .
    + CategoryInfo          : OpenError: (:) [Receive-Job], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionStateBroken

异常的扩展是“后台进程报告了以下消息的错误:”。并且没有任何感觉。

2 个答案:

答案 0 :(得分:0)

据我所知,当删除远程脚本中Start-Job的-Credential参数时,一切顺利。

当我们希望远程会话具有对网络资源的完全访问权限时,使用CredSSP。这就是所谓的双重希望情景。

在你的情况下,你在计算机上构建$ credb这个变量包含B的凭据,但是当你将$ credb作为参数提供给你的远程脚本时,它被序列化了,我打赌第二台计算机无法使用加密的par证书。

尝试在服务器计算机上重新创建凭据,但它也失败了。

答案 1 :(得分:0)

要使用credssp开关,需要配置远程计算机以允许它。但是,即使启用了该功能,也无法将凭据对象直接传递给远程计算机。您可以使用以下代码轻松测试它:

$a="hello world"
Will work: Invoke-Command -ScriptBlock {write-host "hello world"} -session $(get-pssession 2)
Will break: Invoke-Command -ScriptBlock {write-host $a} -session $(get-pssession 2)

您可以使用 ConvertFrom-SecureString 创建一个安全字符串,并将其作为变量传递。