0

enter image description hereWhat I should do to run the Azure powershell commands against release pipeline. When i try to run the Azure powershell command in the "Inline Azure Powershell" i am getting below error.

##[error]The term 'Get-AzKeyVaultSecret' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I am using Hosted agent provided by the Azure pipeline

1 Answer 1

3

There has 2 method.

Suggest you use Azure Powershell Task and change to Inline type.

First method is change the Azure Powershell Task version to 4.*. In 4.*, we build-in the Az.KeyVault module. And it will download the corresponding dll to support this command use.

enter image description here


Or you can continue to use 1.* version task. Just run

Install-Module Az.KeyVault

command firstly to prepare the environment.

Sign up to request clarification or add additional context in comments.

11 Comments

After adding Install-Module Az.KeyVault I am getting a different error #[error]Neither the Azure module nor the AzureRM module was found. If the module was recently installed, retry after restarting the VSTS task agent.
@tjdoubts, Are you still using 1.* version? Because it lacking the azure module and the azure RM module. These 2 modules are the basic of other feature module. I strongly suggest you use 4.* version which we pre-build in almost all basic modules(you don't need to install-module again). Or use 1.* task and run Install-Module command to prepare all basic and feature environments.
For me it is showing only Task Version 1.* . How to update task version
@tjdoubts. Seems you are using an extension task to run the line powershell? Why not using Azure powershell task(provided officially), and select the Script Type as inline?
@tjdoubts. Welcome:-) So it is succeed on your side now? If yes, appreciate for accept this answer
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.