Azure / Azure/azure-powershell
Export-AzAutomationRunbook does not return path correctly if OutputFolder is set
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### 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
```PowerShell
Export-AzAutomationRunbook -AutomationAccountName $AutomationAccountName -ResourceGroupName $AutomationAccountResourceGroupName -Name $RunbookName -OutputFolder $Env:TEMP -Force
```
### Environment data
```PowerShell
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
```PowerShell
az.accounts 4.1.0
az.automation 1.11.1
```
### Error output
```PowerShell
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
```
Contributor guide
Research direction
Start with the Export-AzAutomationRunbook entry point and reproduce the command from a working directory different from OutputFolder. Compare the returned file object's path with the actual exported file; done means the returned object points to the file in the specified OutputFolder.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100