Skip to main content

entra user add

Creates a new user

Usage

m365 entra user add [options]

Alias

m365 aad user add [options]

Options

--displayName <displayName>

The name to display in the address book for the user.

--userName <userName>

The user principal name (someuser@contoso.com).

--accountEnabled [accountEnabled]

Whether the account is enabled. Allowed values: true, false. Defaults to true.

--mailNickname [mailNickname]

The mail alias for the user. By default this value will be extracted from userName.

--password [password]

The password for the user. When not specified, a password will be generated.

--firstName [firstName]

The given name (first name) of the user. Maximum length is 64 characters.

--lastName [lastName]

The user's surname (family name or last name). Maximum length is 64 characters.

--forceChangePasswordNextSignIn

Whether the user should change his/her password on the next login.

--forceChangePasswordNextSignInWithMfa

Whether the user should change his/her password on the next login and setup MFA.

--usageLocation [usageLocation]

A two letter country code (ISO standard 3166). Required for users that will be assigned licenses.

--officeLocation [officeLocation]

The office location in the user's place of business.

--jobTitle [jobTitle]

The user's job title. Maximum length is 128 characters.

--companyName [companyName]

The company name which the user is associated. The maximum length is 64 characters.

--department [department]

The name for the department in which the user works. Maximum length is 64 characters.

--preferredLanguage [preferredLanguage]

The preferred language for the user. Should follow ISO 639-1 Code. Example: en-US.

--managerUserId [managerUserId]

User ID of the user's manager. Specify managerUserId or managerUserName but not both.

--managerUserName [managerUserName]

User principal name of the manager. Specify managerUserId or managerUserName but not both.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

info

To use this command you must be a Global administrator, User administrator or Privileged Authentication administrator.

note

After running this command, it may take a minute before the user is effectively created in the tenant.

This command allows using unknown options. For a comprehensive list of user properties, please refer to the Graph documentation page.

If the specified option is not found, you will receive a Resource 'xyz' does not exist or one of its queried reference-property objects are not present. error.

Examples

Create a user and let him/her update the password at first login

m365 entra user add --displayName "John Doe" --userName "john.doe@contoso.com" --password "SomePassw0rd" --forceChangePasswordNextSignIn

Create a user with job information

m365 entra user add --displayName "John Doe" --userName "john.doe@contoso.com" --password "SomePassw0rd" --firstName John --lastName Doe --jobTitle "Sales Manager" --companyName Contoso --department Sales --officeLocation Vosselaar --forceChangePasswordNextSignIn

Create a user with language information

m365 entra user add --displayName "John Doe" --userName "john.doe@contoso.com" --preferredLanguage "nl-BE" --usageLocation BE --forceChangePasswordNextSignIn

Create a user with a manager

m365 entra user add --displayName "John Doe" --userName "john.doe@contoso.com" --managerUserName "adele@contoso.com"

Response

{
"id": "990e2425-f595-43bc-85ed-b89a44093793",
"businessPhones": [],
"displayName": "John Doe",
"givenName": "John",
"jobTitle": "Sales Manager",
"mail": null,
"mobilePhone": null,
"officeLocation": "Vosselaar",
"preferredLanguage": "nl-BE",
"surname": "Doe",
"userPrincipalName": "john.doe@contoso.com",
"password": "SomePassw0rd"
}
CTRL + M