Add new guest user to azure powershell command line
To add a new guest user to Azure using PowerShell, you can use the following command:
New-AzADUser -DisplayName "New Guest User" -UserPrincipalName "newguestuser@<tenant_name>.onmicrosoft.com" -MailNickname "newguestuser" -AccountEnabled $true -MailEnabled $true -UsageLocation "US" -Force
Replace <tenant_name>
with the name of your Azure Active Directory (AAD) tenant.
Here's a breakdown of the parameters:
-DisplayName
: The display name of the new user.-UserPrincipalName
: The UPN of the new user. This should be in the format<username>@<tenant_name>.onmicrosoft.com
.-MailNickname
: The nickname for the user's email address.-AccountEnabled
: A boolean value indicating whether the account is enabled or not. Set to$true
to enable the account.-MailEnabled
: A boolean value indicating whether the account is mail-enabled or not. Set to$true
to enable mail.-UsageLocation
: The location of the user. This is used for compliance and regulatory purposes.-Force
: A switch that forces the creation of the user without prompting for confirmation.
Once you run this command, the new guest user will be created in your Azure AD tenant. Note that guest users are not assigned to any Azure AD groups by default, so you may need to add them to a group manually if required.
To verify that the user has been created, you can use the following command:
Get-AzADUser -UserPrincipalName "newguestuser@<tenant_name>.onmicrosoft.com"
This will display information about the new user, including their display name, UPN, and account status.