0% found this document useful (0 votes)
36 views

Azure User and Group Commands

Uploaded by

mr.shrey02
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Azure User and Group Commands

Uploaded by

mr.shrey02
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

First time user when they will open the Azure Cloud Shell, will see something like

this!

PowerShell Command Reference

https://learn.microsoft.com/en-us/powershell/module/az.resources/?

Azure Resource Group

— You need location before you can create Resource manager

Get-AzLocation

— To only get locations name

(Get-AzLocation).Location

— To create a resource group

New-AzResourceGroup -Name $Name -Location $Location

— Remove Resource group

Remove-AzResourceGroup -Name $Name

— Create a resource group with a Tag


Azure Resource Manager Lock

Azure User

— To fetch users

Get-AzADUser

— To fetch speci c user

Get-AzADUser -DisplayName $name

— To create a User

New-AzADUser -DisplayName $uname -PasswordProfile $pp -AccountEnabled


$true -MailNickname $nickname -UserPrincipalName $upn

There is restriction on password, we need to set in a very di erent way otherwise you will get an
error

New-AzADUser: Cannot process argument transformation on parameter 'PasswordPro le'.


Cannot convert the "password" value of type "System.String" to type
“Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPass
wordPro le”.

Azure Group

Fetch group

— To fetch any speci c group

Get-AzADGroup -DisplayName $name

— To fetch all the user

Get-AzADGroup

Create New group

New-AzADGroup -DisplayName "DevMachine-NY-01" -MailNickname “DMNY01"

Group Membership

Assign Membership

1. First fetch the group id


fi
fi
fi
ff
fi
1. Either use Get-AzADGroup command to copy group ID
2. Or, If you know the Display name use command to extract the id
$groupid = (Get-AzADGroup -DisplayName $groupname).id
2. Next we need to fetch the id for the user
1. Either we can use New-AzADUser command to fetch Id of the user
2. Or, If you know the Display Name, we can extract the Id for the user

$userid = (Get-AzADUser -DisplayName $username).ID

3. Finally to assign member to any speci c group, use below command

Add-AzADGroupMember -TargetGroupObjectId $groupid -MemberObjectId $userid

Fetch all the members

Get-AzADGroupMember -GroupObjectId $groupid


fi

You might also like