You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Start-ThreadJob中using等方法加载对象至会话失败求助

关于Start-ThreadJob中加载配置文件及using:变量的问题

在使用pwsh7.4时,尝试用Start-ThreadJob将对象加载至作业会话,但using:及其他方法均无法正常工作。

尝试方法一:使用using:变量

执行代码:

$job=Start-ThreadJob -name maya6 -InitializationScript {. $using:profile} -ScriptBlock {ichild}   # ichild是配置文件中定义的别名

返回错误:

InvalidOperation: A Using variable cannot be retrieved. A Using variable can be used only with Invoke-Command, Start-Job, or InlineScript in the script workflow. When it is used with Invoke-Command, the Using variable is valid only if the script block is invoked on a remote computer.
ichild: The term 'ichild' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

尝试方法二:使用-ArgumentList传递参数

执行代码:

$job=start-threadJob {. $args ; ichild} -ArgumentList $profile      # ichild是配置文件中定义的别名

执行receive-job $job时,提示符冻结,且持续出现以下错误:

Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

Environment

PSReadLine: 2.3.4
PowerShell: 7.4.6
OS: Microsoft Windows 10.0.26100
BufferWidth: 170
BufferHeight: 21

Last 49 Keys:

原本以为using:就是专门用于该cmdlet的。


内容的提问来源于stack exchange,提问作者Ralf_Reddings

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 09:01:04