简体   繁体   English

我如何在Powershell中使用大型多行脚本块启动进程?

[英]how i can start process with large multiline script block in powershell?

i wanna start process powershell with script block . 我想用脚本块启动进程powershell。 like this code. 像这样的代码。

start-process powershell.exe -ArgumentList "-noexit","-command {
set-Set-ExecutionPolicy bypass -force
get-help get-process
get-command -commandtype cmdlet
...
}"

The argument for Command should be another element in the ArgumentList not merged into -command. Command的参数应该是ArgumentList中的另一个未合并到-command中的元素。

ie

Start-Process powershell.exe -ArgumentList "-noexit", "-command", "Get-Process"

This applies whether the thing you're executing is a simple command or a longer command (a very long string). 无论您执行的是简单命令还是更长的命令(很长的字符串),这都适用。

you can use this method : 您可以使用此方法:

Start-Process powershell.exe -ArgumentList "-noexit", "-command", "help
dir
get-command
" 

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

相关问题 如何启动进程,暂停2小时,然后在Powershell中终止进程 - How can I start a process, pause for 2 hours and then kill a process in Powershell Powershell start-process -wait参数在远程脚本块中失败 - Powershell start-process -wait parameter fails in remote script block 如何在另一台机器的powershell中启动进程? - How can i start a process in powershell another machine? 如何在PowerShell中继续执行脚本块的行? - How can I continue lines of a script block in PowerShell? 如何使此PowerShell脚本更快地解析大文件? - How can I make this PowerShell script parse large files faster? 如何使用Powershell远程以提升的权限启动批处理脚本 - How can I start a batch script with elevated permissions remotely with powershell 如何在 Visual Studio Code 中以 noprofile 的形式启动 Powershell 脚本 - How can I start Powershell script as noprofile in Visual Studio Code Powershell多行正则表达式块 - powershell multiline regex block 如何使PowerShell运行原始的Start-Process cmdlet而不是PSCX Start-Process cmdlet? - How can I make PowerShell run the original Start-Process cmdlet rather than the PSCX Start-Process cmdlet? PowerShell使用Start-Process在脚本块中执行函数会使用双引号进行奇怪的操作 - PowerShell Executing a function within a Script Block using Start-Process does weird things with double quotes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM