Learn how to create a user account/mailbox through Windows PowerShell in Microsoft Office 365. Most users with technical knowledge prefer to use Windows PowerShell to create a user account in Microsoft Office 365.
Steps to create a user account using Microsoft PowerShell
- In Windows PowerShell, you need to type some commands for installing ActiveAD and MSOnline services.
Install-Module –Name AzureAD
Install-Module –Name MSOnline - Now enter the below command to connect to Office 365 admin account.
$UserCredential = Get-Credential - A new popup will appear on the screen. Type your mailbox ID and password, and click the OK button.
- After logging in with the online exchange mailbox, you need to connect to Msolservice. To run this service, enter the given command.
- Connect-MsolService -Credential $UserCredential
- Create a user account product license and location.
- Verify the producer license before creating an account. Type the command to verify.
- Display an error if you are not connected to MsolService or view a list of all users’ mailboxes.
- Type the below command to check the license
- Get-MsolAccountSku
- You can enter the following command to create a user account.
- New-MsolUser DisplayName “username” -FirstName “user first name” -LastName “user surname”-UserPrincipalName UserName@domainname.onmicrosoft.com UsageLocation In -LicenseAssignment DomainName:ENTERPRISEPACK
- If you do not want to assign the license to the user, you can skip this command.
- If you want to modify the password, you must enter the command after the user mailbox, and default password has been created.
Set-MsolUserPassword -UserPrincipalName username@domain.onmicrosoft.com -NewPassword xxxxxxxxxx