I trying to run the below script via azure pipeline task (Az CLI) and pipeline is running on self-hosted agent.. I'm getting Error: Cannot process command because of one or more missing mandatory parameters: ServicePrincipalId,ServicePrincipalPass,ServicePrincipalTenant AzureRegistryName.
Can any one help me out this. Thanks in advance.. Code will be there in git hub:- https://github.com/goyalmohit/acr-cleanup/blob/master/acr-cleanup.ps1
In script I passed values like this [String] $ServicePrincipalId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Like this remaining values like password, tenant, subscription name, Acr Name passed same way..
From the PowerShell script, you are using Mandatory Parameters. The value needs to be input during the process of executing PowerShell script.
In Azure DevOps Pipeline, it does not support interactive input, so the script cannot get a valid value.
To solve this issue, you can define the value of the parameters in PowerShell Task -> Argument.
For example:
- task: PowerShell@2
displayName: 'PowerShell Script'
inputs:
targetType: filePath
filePath: ./test.ps1
arguments: '-ServicePrincipalId xxx -ServicePrincipalPass xxx'
Then the value will pass to the PowerShell Parameters successfully.
Update:
Azure CLI task:
- task: AzureCLI@2
displayName: 'Azure CLI test.ps1'
inputs:
azureSubscription: xxx
scriptType: ps
scriptPath: test.ps1
arguments: '-ServicePrincipalId xxx -ServicePrincipalPass xxx
Update2: