AzADUser Cmdlet
The AzADUser cmdlets are used to manage Azure Active Directory (Azure AD) users in your Azure environment. These cmdlets allow you to create, retrieve, update, and delete user accounts, as well as manage their properties and group memberships.
Syntax
To see the syntax for a specific cmdlet, you can use the Get-Help cmdlet in PowerShell. For example:
Get-Help Get-AzADUser -FullCmdlets
The AzADUser module includes the following cmdlets:
- Get-AzADUser: Retrieves Azure AD users.
- New-AzADUser: Creates a new Azure AD user.
- Set-AzADUser: Updates an existing Azure AD user.
- Remove-AzADUser: Deletes an Azure AD user.
- Update-AzADUser: Alias for- Set-AzADUser.
Get-AzADUser Example
# Get a user by their User Principal Name (UPN)
Get-AzADUser -Filter "UserPrincipalName eq 'testuser@yourdomain.com'"
# Get all users
Get-AzADUser
# Get a user by object ID
Get-AzADUser -ObjectId "a1b2c3d4-e5f6-7890-1234-567890abcdef"
# Filter users by display name
Get-AzADUser -Filter "DisplayName eq 'John Doe'"New-AzADUser Example
# Create a new user with a display name and UPN
New-AzADUser -DisplayName "Jane Smith" -UserPrincipalName "janesmith@yourdomain.com" -Password "P@$$wOrd123!"
# Create a user with additional properties
New-AzADUser -DisplayName "Peter Jones" -UserPrincipalName "peterjones@yourdomain.com" -Password "AnotherSecureP@ssword" -ForceChangePasswordNextLogin $true -AccountEnabled $trueSet-AzADUser Example
# Get a user
$user = Get-AzADUser -ObjectId "a1b2c3d4-e5f6-7890-1234-567890abcdef"
# Update the user's display name
Set-AzADUser -ObjectId $user.Id -DisplayName "Jane Smith Updated"
# Disable a user account
Set-AzADUser -ObjectId $user.Id -AccountEnabled $falseRemove-AzADUser Example
# Remove a user by Object ID (use with caution!)
Remove-AzADUser -ObjectId "a1b2c3d4-e5f6-7890-1234-567890abcdef" -ForceParameters
The AzADUser cmdlets accept a variety of parameters to filter, specify, and modify user objects. Common parameters include:
| Parameter | Description | Type | Required | 
|---|---|---|---|
| -ObjectId | The object ID of the user. | System.String | No (unless filtering by other properties) | 
| -Filter | A string representing an OData filter expression to query users. | System.String | No | 
| -DisplayName | The display name of the user. Used when creating or updating users. | System.String | No | 
| -UserPrincipalName | The User Principal Name (UPN) of the user. Used when creating or updating users. | System.String | No | 
| -Password | The password for the new user. | System.String | No (required for New-AzADUserif not specified otherwise) | 
| -AccountEnabled | Specifies whether the user account is enabled. | System.Boolean | No | 
| -ForceChangePasswordNextLogin | Indicates whether the user must change their password at next sign-in. | System.Boolean | No | 
| -Force | Suppresses confirmation messages for operations that might be destructive. | System.Management.Automation.SwitchParameter | No | 
Related Cmdlets
- Get-AzADGroup
- Add-AzADGroupMember
- Remove-AzADGroupMember
- Get-AzRoleAssignment
- New-AzRoleAssignment