title: How to set and retrieve variable value for condition in YAML Pipelines?
body: <p>The condition on &quot;Deploy_Infrastructure&quot; is using the variable isInfraCreated. The value of isInfraCreated keeps returning 'unknown', even though the PowerShell script sets the values. What am I doing wrong here?</p>
  <pre class="lang-yaml prettyprint-override"><code>trigger:
  - main
  
  stages:
  - stage: development
    variables:
      isInfraCreated: &quot;unknown&quot;
      aksClusterName: &quot;bla-aks&quot;
      aksResourceGroup: &quot;bla-aks-resources-01&quot;
    jobs:
    - job: Prepare
      steps:
      - task: AzureCLI@2
        displayName: 'Azure PowerShell: Determine isInfraCreated'
        inputs:
          azureSubscription: 'myAzureSubscription'
          scriptType: 'pscore'
          scriptLocation: 'inlineScript'
          inlineScript: |
            $aksResource = az aks show --name $(aksClusterName) --resource-group $(aksResourceGroup)
            $aksResource
            if ($aksResource -eq $null)
            {
              Write-Host &quot;##vso[task.setvariable variable=isInfraCreated]$false&quot;
              $isInfraCreated = $false
              $env:isInfraCreated = $false
            }
            else 
            {
              Write-Host &quot;##vso[task.setvariable variable=isInfraCreated]$true&quot;
              $isInfraCreated = $true
              $env:isInfraCreated = $true
            }
    - job: Deploy_AKS_Infrastructure 
      condition: and(succeeded(), eq(variables.isInfraCreated, 'False'))
  
  </code></pre>