PowerShell: running commands in sequence

79 Views Asked by At

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

1

There are 1 best solutions below

0
Jahnavi On

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