Search code examples
azureazure-automationazure-runbookhybrid-runbook-worker

Calling child runbook results in The term '.\RunbookName.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program


I am trying to do POC on working with child runbooks. As part of this POC I created a simple runbook Child.ps1 with below content:

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"
}

and a Parent Runbook, which calls the child runbook by passing the parameter as shown below:

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

When I test the parent runbook I get following error:

.\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

I am trying to test this using Hybrid Worker. I am able to successfully test the child runbook. Any ideas why this is failing. AM I missing anything here?


Solution

  • In general, this should work. However, you may get this error message if the child runbook is not published. Is it published?