作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当您使用Start-Job
开始新工作时,可以将其传递给ScriptBlock
和InitializationScript
,例如:
Function FOO {
Write-Host "HEY"
}
Start-Job -ScriptBlock {FOO} -InitializationScript {
Function Foo { $function:FOO }
} | Wait-Job | Receive-Job
InitializationScript
作为Base64编码的命令行参数传递。
CreateProcess()
函数,命令ine的最大大小为32,768个字符。所以很明显,如果您的Base64编码的
InitializationScript
接近此大小,则可能会收到错误消息。
ScriptBlock
参数的大小限制。有人可以确认没有限制吗?
ScriptBlock
是通过标准输入传输到子进程的?
最佳答案
脚本块实际上有限制。您可以通过3种方式使用scriptblock运行命令:
$scriptblock = '
get-help
get-command
dir
get-help *command*
get-command *help*
'
iex $scriptblock
$scriptblock = {
get-help
get-command
dir
get-help *command*
get-command *help*
}
Start-Process powershell.exe -ArgumentList "Command $scriptblock"
Start-Process powershell {iex '
get-help
get-command
dir
get-help *command*
get-command *help*
'
}
关于powershell - PowerShell中Start-Job的ScriptBlock/InitializationScript的最大大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40086313/
我是一名优秀的程序员,十分优秀!