How to Create a User in Azure AD: Step-by-Step Guide
To create a user in Azure AD, use the
Azure Portal by navigating to Azure Active Directory > Users > New user and filling in the details. Alternatively, use the AzureAD PowerShell module with the New-AzureADUser command to create users programmatically.Syntax
There are two common ways to create a user in Azure AD: via the Azure Portal UI or using PowerShell commands.
- Azure Portal: Navigate to
Azure Active Directory > Users > New user, then enter user details like name, username, and password. - PowerShell: Use the
New-AzureADUsercmdlet with parameters to specify user properties.
powershell
New-AzureADUser -DisplayName <string> -UserPrincipalName <string> -AccountEnabled <bool> -MailNickname <string> -PasswordProfile @{ForceChangePasswordNextLogin=$true; Password='<string>'}Example
This example shows how to create a new user in Azure AD using PowerShell. It sets the display name, username, enables the account, and sets a temporary password that the user must change on first login.
powershell
Connect-AzureAD
$passwordProfile = @{ForceChangePasswordNextLogin=$true; Password="P@ssw0rd123"}
New-AzureADUser -DisplayName "Jane Doe" -UserPrincipalName "janedoe@yourtenant.onmicrosoft.com" -AccountEnabled $true -MailNickname "janedoe" -PasswordProfile $passwordProfileOutput
ObjectId DisplayName UserPrincipalName
-------- ----------- -----------------
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Jane Doe janedoe@yourtenant.onmicrosoft.com
Common Pitfalls
- Not connecting to Azure AD before running PowerShell commands causes errors. Always run
Connect-AzureADfirst. - Using weak passwords or not setting
ForceChangePasswordNextLogincan cause security risks. - Incorrect
UserPrincipalNameformat will prevent user creation.
powershell
## Wrong way: Missing Connect-AzureAD New-AzureADUser -DisplayName "John" -UserPrincipalName "john@tenant.com" -AccountEnabled $true -MailNickname "john" -PasswordProfile @{ForceChangePasswordNextLogin=$true; Password="Pass1234"} ## Right way: Connect-AzureAD New-AzureADUser -DisplayName "John" -UserPrincipalName "john@tenant.com" -AccountEnabled $true -MailNickname "john" -PasswordProfile @{ForceChangePasswordNextLogin=$true; Password="Pass1234"}
Quick Reference
Here is a quick summary of key parameters for New-AzureADUser:
| Parameter | Description |
|---|---|
| -DisplayName | Full name of the user |
| -UserPrincipalName | User's login name (email format) |
| -AccountEnabled | Boolean to enable or disable the account |
| -MailNickname | Alias for the user |
| -PasswordProfile | Password settings including temporary password and change requirement |
Key Takeaways
Always connect to Azure AD using Connect-AzureAD before creating users with PowerShell.
Use strong temporary passwords and require users to change them at first login.
UserPrincipalName must be a valid email format within your Azure AD tenant.
Azure Portal offers a simple UI for creating users without scripting.
PowerShell allows automation and bulk user creation with precise control.