Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 在远程CredSSP调用中启动作业时出现问题_Powershell_Powershell 2.0_Credentials_Background Process_Powershell Remoting - Fatal编程技术网

Powershell 在远程CredSSP调用中启动作业时出现问题

Powershell 在远程CredSSP调用中启动作业时出现问题,powershell,powershell-2.0,credentials,background-process,powershell-remoting,Powershell,Powershell 2.0,Credentials,Background Process,Powershell Remoting,从机器X连接到Y,用CredA作为CredSSP,然后经过CredB,我想用CredB在机器Y上开始一项工作 虽然我可以将RDP作为X放入机器Y中,并成功地在本地创建一个作为Y的作业,但当我使用远程处理时。我犯了一个错误。下面是根据问题复制的示例代码 $sb1 = {param($cred) $cred ; write-host "started" ; start-job -Credential $cred -ScriptBlock {"yo"} | Wait-Job | Receive-J

从机器X连接到Y,用CredA作为CredSSP,然后经过CredB,我想用CredB在机器Y上开始一项工作

虽然我可以将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秒后(可能是超时),我没有看到在y上的任务管理器中创建任何进程 (当我在scriptblock中加上“yo”来睡觉时,我只是想看看)

下面是返回的错误

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

异常的扩展是“后台进程报告了一个错误,并显示以下消息:”,并且没有内部异常。

据我所知,在远程脚本中删除启动作业的-Credential参数时,一切都很顺利

当我们希望远程会话能够完全访问网络资源时,可以使用CredSSP。这就是所谓的双希望情景

在您的情况下,您在计算机A上建立$CUBB,这个变量包含B的凭据,但是当您将$CUBB作为参数写入远程脚本时,它被序列化,并且我确信第二台计算机不能使用证书的加密PAR。
i尝试在服务器计算机上重新创建凭据,但也失败。

要使用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)

您可以做的是使用convertfromsecurestring创建一个安全字符串,并将其作为变量传递。

几个问题:您是否在X上启用CredSSP作为客户端,并将其委托给Y?你在Y上启用CredSSP作为客户机和服务器吗?你如何构建$Creda和$CredBIt?这让我很费时,但我会复制。