Skip to content

Export-AzAutomationRunbook does not return path correctly if OutputFolder is set #27944

Open
@ld0614

Description

@ld0614

Description

Running the command

Export-AzAutomationRunbook -AutomationAccountName $AutomationAccountName -ResourceGroupName $AutomationAccountResourceGroupName -Name $RunbookName -OutputFolder $Env:TEMP -Force

from any working directory other than the local temp folder causes the returned file object to be invalid

It appears that there is a hardcoded assumption that the file is being exported to the local working directory and as such the file object returned has the full path of $WorkingDirectory\RunbookName.ps1

The file is successfully exported to the correct location so its just an script output issue

Issue script & Debug output

Export-AzAutomationRunbook -AutomationAccountName $AutomationAccountName -ResourceGroupName $AutomationAccountResourceGroupName -Name $RunbookName -OutputFolder $Env:TEMP -Force

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

az.accounts 4.1.0
az.automation 1.11.1

Error output

Mode                : larhs
ModeWithoutHardLink : larhs
BaseName            : ScriptName.ps1
ResolvedTarget      : 
Target              : 
LinkType            : 
Name                : ScriptName.ps1
Parent              : C:\WorkingDirectory
Root                : C:\
Exists              : False
FullName            : C:\WorkingDirectory\ScriptName.ps1
Extension           : .ps1
CreationTime        : 01/01/1601 00:00:00
CreationTimeUtc     : 01/01/1601 00:00:00
LastAccessTime      : 01/01/1601 00:00:00
LastAccessTimeUtc   : 01/01/1601 00:00:00
LastWriteTime       : 01/01/1601 00:00:00
LastWriteTimeUtc    : 01/01/1601 00:00:00
LinkTarget          : 
UnixFileMode        : -1
Attributes          : -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions