解决了故障调用工作流程:“ CommandNotFoundException”

时间:2019-07-31 20:53:37

标签: powershell

我正在使我们的SCCM后置备过程自动化。我的所有功能也都按照我想要的方式工作,但是有些功能需要花费很多时间来执行更新,并且我想同时执行其他任务以加快过程。

我的拼写似乎正确,这是我的第一个powershell项目。

此代码是在定义了我的功能之后

#RUN FUNCTIONS
workflow Main-flow
{
Parallel
{
    Set-powerCfg
    Set-groupPolicy 
    Get-DellUpdates
}
Run-configManager
Parallel
{
    Test-msEdge
    Get-PulseSecure
    Run-symCheck
    set-xxxLaptopPwd
}
Run-SCUpdater
#Print Log
Get-Content -Path .\log.txt
#Hold Script
Write-Host "Script Complete" 
}
Main-flow
Read-Host -Prompt “Press Enter to exit”
exit

我希望我的程序在每个并行块同时运行其功能的情况下执行,直到完成,然后再运行以下功能。 这是我收到的错误消息:

The term 'Main-flow' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At V:\Home\xxxxxxxx\Scripts\WorkflowTest.ps1:311 char:10
+ Main-flow <<<< 
    + CategoryInfo          : ObjectNotFound: (Main-flow:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

此简单的hello world工作流程在空脚本中生成相同的错误。

workflow helloworld {

“Hello World”

}
helloworld

产生相同的错误。

谢谢JS2010,我正在运行旧版本的powershell。

0 个答案:

没有答案