0
votes

I am trying to create an Azure Automation job to create a new Azure Automation Runbook. I am using the following to try to get it to work.

    $Context = New-AzureStorageContext $storageAccountName $storageAccountKey
    $Path = Get-AzureStorageFile -ShareName "qdrive" -Path "TestWorkFlow.ps1" -Context $Context |Select-object Name |Out-String

    Import-AzureRMAutomationRunbook -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Path $Path -Type PowerShellWorkflow -Force -Name $Name -Published

I get an error message of Import-AzureRMAutomationRunbook:Cannot find path 'C:\Windows\System32\ Name ------ TestWorkFlow.ps1

I need help figuring out how to send the path of the file to the $path variable in a UNC and not a URI.

Thanks!

2

2 Answers

1
votes

The cmdlet needs to take a fully qualified path to the runbook .ps1 file, where the local machine has access to that path via normal local file system referencing. It looks like in this case $Path contains “Name ------ TestWorkFlow.ps1” – so therefore you are not storing the path in $Path correctly, hence the failure.

0
votes

The $path variable for the -Path switch to the cmdlet needs to contain the full path, Including the filename itself. Like, "C:\Users\Johndoe\TestWorkFlow.ps1". Hope this helps.