Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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 在系统帐户下运行时,对Linux主机的新PSSession被冻结_Powershell - Fatal编程技术网

Powershell 在系统帐户下运行时,对Linux主机的新PSSession被冻结

Powershell 在系统帐户下运行时,对Linux主机的新PSSession被冻结,powershell,Powershell,我试图通过Jenkins在系统帐户下运行Powershell脚本 $DebugPreference = 'Continue' $dt=get-date -Format "MM-dd-yyyy-HH-mm-ss-fff" Start-Transcript -Path "C:\install\transcript-$dt.txt" dir env: $cmdline = $((Get-CimInstance win32_process -Filter &quo

我试图通过Jenkins在系统帐户下运行Powershell脚本

$DebugPreference = 'Continue'
$dt=get-date -Format "MM-dd-yyyy-HH-mm-ss-fff"
Start-Transcript -Path "C:\install\transcript-$dt.txt"
dir env:
$cmdline = $((Get-CimInstance win32_process -Filter "ProcessID=$PID" | ? { $_.processname -eq "pwsh.exe" }).commandline)
if($cmdline -like "*pwsh.exe*")
{
    write-host "Powershel 7 continue" 
    Write-Host "Before Start-session"
    $s = New-PSSession -HostName ip -UserName user -verbose  -KeyFilePath C:\.ssh\id_rsa
    Write-Host "After Start-session"
  
}else{
    Start-Process pwsh.exe -Wait -PassThru  -ArgumentList "-NonInteractive -ExecutionPolicy Bypass -File $($MyInvocation.MyCommand.Definition)"
}    
stop-transcript

   
我的问题是,写入主机“启动会话后”从未到达

第一个启动脚本显示,脚本使用pwsh.exe再次启动

第二个启动记录显示启动会话之前的输出

在此之后,没有任何内容添加到成绩单中,该过程将继续运行

当脚本在管理员帐户下运行时,它工作正常


我如何调试它?

问题是SSH指纹不可信。 当我通过命令行而不是通过Jenkins direct运行脚本时,我得到以下输出:

在我回答“是”之后,一切都正常了。
Jenkings的工作现在正在进行中。

你可以使用
-Debug
但是,我很难理解你的意思。怎么可能永远达不到呢?这需要无限长的时间。它只是在执行新PSSession时挂起。您可以将它用作作业,这样它就不会等待它终止。你是怎么用的?我看不到正在使用该会话