Azrael
Azrael

Reputation: 1

PowerShell: running commands in sequence

I am rather new to PowerShell, still getting my head around but at the moment, I am trying to create a script in PS Ise that starts with: Connect-AzureAD, followed by Get-AzureUserAD but whatever I have tried the script won't keep running after the first line:Connect to AzureAD. If somebody can explain me what I am doing wrong.

Thank You

REF: 1-Connect-AzureAD 2-Get-AzureADUser - Searchstring......

Tried to use the ; between each command and && with no success Connect-AzureAD PS ISE

Upvotes: -1

Views: 256

Answers (1)

Jahnavi
Jahnavi

Reputation: 8018

Get-AzureUserAD but whatever I have tried the script won't keep running after the first line:Connect to AzureAD:

As given by @Mathias R. Jessen, there is no command called Get-AzureUserAD in Azure PowerShell commands.

Instead, you need to give Get-AzureADUser command to list out the users as shown below.

Once it is done, you can also execute Get-AzureADUserMembership to retrieve the user memberships.

Note: Make sure that the Azure AD module is installed successfully without any conflicts. Install-Module -Name AzureAD

Connect-AzureAD
Get-AzureADUser -ObjectId "xxxx"
Get-AzureADUserMembership  -ObjectId "xxx"

enter image description here

If you are trying to get the AD user by searching it with a string, use below format.

Get-AzureADUser -SearchString "jahnavi"

enter image description here

Upvotes: 0

Related Questions