'Get-AzureADUser' is not recognized as a name of a cmdlet in github

I'm scratching my head from last couple of days with this strange issue. I'm using GitHub workflow to run few powershell commands.

So when I tried to runGet-AzureADUser -ObjectId $User-emailI'm keep getting

The term 'Get-AzureADUser' is not recognized as a name of a cmdlet, | function, script file, or executable program. Check the spelling of the | name, or if a path was included, verify that the path is correct and try | again.

I used below commands to install the module and check if the module is installed or not. It shows up all green.Install the Module:

Install-Module AzureAD -Scope CurrentUser -Repository PSGallery -Force

Check If Module installed:

Find-Module -Name AzureAD

or

Get-Module -ListAvailable | Where-Object {$_.Name -like '*AzureAD*'}

It's shows it is installed.

However if I'm trying to use

Find-Command -Repository PSGallery -Name Get-AzureADUser this shows

Environments : {[AzureChinaCloud, AzureChinaCloud], [AzureUSGovernment, AzureUS Government], [AzureCloud, AzureCloud]}
Context : Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext

my workflow looks like this:

- name: Run Azure PowerShell script - Add users to AD Group uses: azure/powershell@v1 with: azPSVersion: "latest" inlineScript: | Install-Module AzureAD -Scope CurrentUser -Repository PSGallery -Force $securePassword = "xxxx" $psCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "clientid" , $securePassword Connect-AzAccount -Credential $psCred -TenantId "tenat_id" -ServicePrincipal $info = Get-AzureADUser -ObjectId $User-email Add-AzureADGroupMember -ObjectId "aad_object_id" -RefObjectId $info.ObjectId ....

Can anyone help me how can I achieve this?

1

1 Answer

Check with the commandlets below: After Installing Azure ad

Install-Module AzureAD -Scope CurrentUser -Repository PSGallery -Force

Make sure to add to import the module to your library of whatever you are using in your pipeline script.

Import-module azureadOrImport-module azureadpreviewMake sure to Connect to azure ad using

$Credential = Get-Credential
Connect-AzureAD -Credential $Credential 

enter image description here

To get the AzureAD modules to be used.

And then try to give Azure ad commands and you may look into @Azeem's reference.

Get-AzureADUser

enter image description here

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like