Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ld0614 opened this issue Jun 12, 2025 · 2 comments
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Possible-Solution Similar-Issue

Comments

@ld0614
Copy link

ld0614 commented Jun 12, 2025

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
@ld0614 ld0614 added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jun 12, 2025
Copy link

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

I put together a script to work around this issue while there is no official fix:

https://github.com/achaika80/Powershell/tree/master/Get-RunbooksFromAzureAA

Reference:

Powered by issue-sentinel

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jun 12, 2025
@ld0614
Copy link
Author

ld0614 commented Jun 12, 2025

Here are some similar issues that might help you. Please check if they can solve your problem.

Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

I put together a script to work around this issue while there is no official fix:

https://github.com/achaika80/Powershell/tree/master/Get-RunbooksFromAzureAA

Reference:

Powered by issue-sentinel

This does not appear to be a related issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Possible-Solution Similar-Issue
Projects
None yet
Development

No branches or pull requests

1 participant