- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 PowerShell 工作流引入到一些现有脚本中,以利用并行运行功能。
目前在我不得不使用的工作流程中:
Inline
{
Import-Module My.Modules
Execute-MyModulesCustomFunctionFromImportedModules -SomeVariable $Using:SomeVariableValue
}
最佳答案
文章在 http://www.powershellmagazine.com/2012/11/14/powershell-workflows/确认必须导入模块然后使用它们就是它的工作原理 - MS 通过为其所有常见的 PowerShell 命令创建 WF 事件来解决这个问题:
General workflow design strategy
It’s important to understand that the entire contents of the workflow get translated into WF’s own language, which only understands activities. With the exception of a few commands, Microsoft has provided WF activities that correspond to most of the core PowerShell cmdlets. That means most of PowerShell’s built-in commands—the ones available before any modules have been imported—work fine.
That isn’t the case with add-in modules, though. Further, because each workflow activity executes in a self-contained space, you can’t even use Import-Module by itself in a workflow. You’d basically import a module, but it would then go away by the time you tried to run any of the module’s commands.
The solution is to think of a workflow as a high-level task coordination mechanism. You’re likely to have a number of InlineScript{} blocks within a workflow because the contents of those blocks execute as a single unit, in a single PowerShell session. Within an InlineScript{}, you can import a module and then run its commands. Each InlineScript{} block that you include runs independently, so think of each one as a standalone script file of sorts: Each should perform whatever setup tasks are necessary for it to run successfully.
关于powershell - 如何让 PowerShell WorkFlow 访问以前导入的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25663034/
我是一名优秀的程序员,十分优秀!