简体   繁体   English

使用来自另一个 Powershell 脚本的参数调用 PowerShell 脚本并绕过

[英]Call PowerShell script with argument from another Powershell script with bypass

I need to call a ps1 Script during going through another ps1 file.我需要在浏览另一个 ps1 文件期间调用 ps1 脚本。 The new call shouldn't interrupt the script which I'm going through.新调用不应中断我正在执行的脚本。 Also I always call the Powershell scripts like this: powershell -ExecutionPolicy Bypass -File file.ps1 -param log_14.txt due to execution policies.此外,由于执行策略,我总是像这样调用 Powershell 脚本: powershell -ExecutionPolicy Bypass -File file.ps1 -param log_14.txt

I tried following code in my .ps1 script, sadly it doesn't work:我在我的 .ps1 脚本中尝试了以下代码,遗憾的是它不起作用:

    Start-Job PowerShell -Argument "sort.ps1 -file $fileName"

Any ideas how to make it work?任何想法如何使它工作?

Try this:尝试这个:

$job = Start-Job -ScriptBlock {
  powershell -ExecutionPolicy Bypass -File "filepath.ps1 Param"
}
$job | wait-job | receive-job

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM