Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install AzureAd module using Install-Module -Name AzureAD in ADO pipeline

I am trying to execute Get-AzureADServicePrincipal in a azure powershell task in ADO. I need to get service principal for me to then connect to get ServicePrincipalId and ServicePrincipalkey. As part of this I am trying the below, as an inline script

Install-Module -Name AzureAD Get-AzureADServicePrincipal

But this keeps failing as,

WARNING: User declined to install module (AzureAD)

[error]The term 'Get-AzureADServicePrincipal' is not recognized as the name of a cmdlet

Please could some one help? Thanks

like image 968
makil Avatar asked Oct 24 '25 11:10

makil


2 Answers

Install-Module is prompting for user input. Specify the -Force flag.

like image 100
Daniel Mann Avatar answered Oct 26 '25 01:10

Daniel Mann


If you are using host agent. Better to install a module only for the current user

This example downloads and installs the newest version of a module, only for the current user. Also add -Force

Install-Module -Name PowerShellGet -Scope CurrentUser -Force

Then you need to call the Connect-AzureAD cmdlet before calling any other cmdlets.

Finally Get-AzureADServicePrincipal.

like image 23
PatrickLu-MSFT Avatar answered Oct 26 '25 01:10

PatrickLu-MSFT