调用子Runbook导致术语'。\ RunbookName.ps1'无法识别为cmdlet,函数,脚本文件或可操作程序的名称

时间:2018-04-11 16:47:31

标签: azure azure-automation azure-runbook hybrid-runbook-worker

我正在努力做POC与儿童Runbook一起工作。作为这个POC的一部分,我创建了一个简单的Runbook Child.ps1,内容如下:

Param(
    [string]$FolderPath
)
$path = $FolderPath
if(! (Test-Path $path))
{
    New-Item -Type dir -Path $path
    Write-Output "Created directory '$path'"
}
else
{
    Write-Output "Directory '$path' already exists"
}

和一个Parent Runbook,它通过传递参数来调用子Runbook,如下所示:

.\Child.ps1 -FolderPath "C:\TestPath"

当我测试父Runbook时,我得到以下错误:

.\Child.ps1 : The term '.\Child.ps1' 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 line:1 char:1
+ .\Child.ps1 -FolderPath "C:\TestPath"
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.\Child.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我正在尝试使用Hybrid Worker进行测试。我能够成功测试子Runbook。任何想法为什么这是失败的。我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

一般来说,这应该有效。但是,如果未发布子Runbook,则可能会收到此错误消息。是发布了吗?