skip to Main Content

When I am invoking a yaml file in my Azure Pipeline, sample is

 - task: AzurePowerShell@5
      displayName: 'Execute PowerShell Script on Target VMs'
      inputs:
        azureSubscription: ${{ variables.SERVICE_CONNECTION_NAME }}
        pwsh: true
        ScriptType: 'FilePath'
        ScriptPath: 'pipeline-scripts/Deploy-ALZDomainControllers.ps1'
      env:
        LOCATION: $(LOCATION)
        TOP_LEVEL_MG_PREFIX: $(TOP_LEVEL_MG_PREFIX)
        UPSTREAM_RELEASE_VERSION: $(UPSTREAM_RELEASE_VERSION)
        IS_PULL_REQUEST: $(IS_PULL_REQUEST)

I get this error:

##[debug]Caught exception from task script.
##[debug]Error record:
##[debug]The Azure PowerShell version '' specified is not in the correct format. Please check     the format. An example of correct format is 1.0.1
##[debug]At D:a_tasksAzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb623.236.0AzurePowerShell.ps1:46 char:5
##[debug]+     throw (Get-VstsLocString -Key InvalidAzurePsVersion -ArgumentList ...
##[debug]+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##[debug]    + CategoryInfo          : OperationStopped: (The Azure Power...format is 1.0.1:String) [], RuntimeException
##[debug]    + FullyQualifiedErrorId : The Azure PowerShell version '' specified is not in the correct format. Please check the     format. An example of correct format is 1.0.1
##[debug] 
##[debug]Script stack trace:
##[debug]at <ScriptBlock>, D:a_tasksAzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb623.236.0AzurePowerShell.ps1: line 46
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]at <ScriptBlock>, <No file>: line 22
##[debug]at <ScriptBlock>, <No file>: line 18
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]System.Management.Automation.RuntimeException: The Azure PowerShell version '' specified is not in the correct format. Please check the format. An example of correct format is 1.0.1
##[error]The Azure PowerShell version '' specified is not in the correct format. Please check the format. An example of correct format is 1.0.1
##[debug]Processed: ##vso[task.logissue source=TaskInternal;type=error]The Azure PowerShell version '' specified is not in the correct format. Please check the format. An example of correct format is 1.0.1
##[debug]Processed: ##vso[task.complete result=Failed]

I have no version specification – tried with and withpoot but consistenly the same argument error.

Suggestions please

Have tried using Version with and without quote marks etc but always complains abouyt version.

I want to install and invoke the Azure AZ module and not use the AzureRM module as it is deprecated and some of the commands from Az.Control are what I need to use in my script

2

Answers


  1. The Azure PowerShell version ” specified is not in the correct format. Please check the format. An example of correct format is 1.0.1

    Checked the Azure PowerShell task definition, the cause of the issue is that you need to define the azurePowerShellVersion or preferredAzurePowerShellVersion in the Azure PowerShell task.

    For example:

    - task: AzurePowerShell@5
      displayName: 'Execute PowerShell Script on Target VMs'
      inputs:
        azureSubscription: ${{ variables.SERVICE_CONNECTION_NAME }}
        pwsh: true
        ScriptType: 'FilePath'
        ScriptPath: 'pipeline-scripts/Deploy-ALZDomainControllers.ps1'
        azurePowerShellVersion: 'LatestVersion'
      env:
        LOCATION: $(LOCATION)
        TOP_LEVEL_MG_PREFIX: $(TOP_LEVEL_MG_PREFIX)
        UPSTREAM_RELEASE_VERSION: $(UPSTREAM_RELEASE_VERSION)
        IS_PULL_REQUEST: $(IS_PULL_REQUEST)
    

    Or

    - task: AzurePowerShell@5
      displayName: 'Execute PowerShell Script on Target VMs'
      inputs:
        azureSubscription: ${{ variables.SERVICE_CONNECTION_NAME }}
        pwsh: true
        ScriptType: 'FilePath'
        ScriptPath: 'pipeline-scripts/Deploy-ALZDomainControllers.ps1'
        preferredAzurePowerShellVersion: '3.1.0'
      env:
        LOCATION: $(LOCATION)
        TOP_LEVEL_MG_PREFIX: $(TOP_LEVEL_MG_PREFIX)
        UPSTREAM_RELEASE_VERSION: $(UPSTREAM_RELEASE_VERSION)
        IS_PULL_REQUEST: $(IS_PULL_REQUEST)
    

    For more detailed info, you can refer to this doc: AzurePowerShell@5 – Azure PowerShell v5 task

    Login or Signup to reply.
  2. Kevin’s answer will cover your question. Additionally, use the assistant on the yaml editor (Use task assistant). It will help you to check all the required fields:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search