I have read multiple questions regarding this but I can't make it work.
I want to pass a powershell object (hashtable) between tasks.
I set the hashtable here:
$output += @{
roleAssignments = $roleAssignments
subscriptionName = "$workloadName-$omgevingKeyLower"
subscriptionManagementGroupId = $workloadName
subscriptionTags = $tags
subscriptionWorkload = $subscriptionWorkload
virtualNetworkAddressSpace = $virtualNetworkAddressSpace
}
# Output the entire object as JSON
# the json part is optional as far as I'm concerned. Rather have plain hashtable
$outputJson = $output | ConvertTo-Json -Compress
Write-Output $output
I see the hashtable is returned at conclusion of the task that reads the file and sets the hashtable.
This is my pipeline code:
- task: PowerShell@2
displayName: 'Read YAML file'
name: ReadYaml
inputs:
targetType: filePath
filePath: ./scripts/readYaml.ps1
arguments: '-filePath ${{ parameters.yamlFilePath }}'
- task: AzureCLI@2
displayName: 'Create management group'
inputs:
azureSubscription: iaCS-ASE
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
echo "print the output"
& az account management-group create --name $(output.subscriptionManagementGroupId) --parent Landingzones
I want to do $(output.subscriptionName) here. I've tried converting to and from json. accessing keys with and without []. I'm at a loss. Locally in PowerShell it works fine. But ado throws a wrench in the works.
