n3s0 || journal

Creating New User Using PowerShell On Microsoft 365

Posted on 2 mins

PowerShell Microsoft 365

Overview

This post provides my notes on how to add a new user to the Microsoft 365 portal using PowerShell.

References for this article can be found in the references section.

Adding A User

Before starting, needed to login using the Connect-MSolService Cmdlet.

The following command will add a new user profile to the Microsoft 365 portal. Little more explaination is provided after the code snippet.

New-MsolUser -DisplayName "Jane Doe" `
	-FirstName Jane `
	-LastName Doe `
	-UserPrincipalName "JDoe@example.com" `
	-UsageLocation US `
	-LicenseAssignment example:O365_BUSINESS

Little overview of what the command above does. First of all. It creates a new user instance using the New-MsolUser Cmdlet. Note that this is pretty close to bare minimum for what you can do with this Cmdlet. But, with that it sets the following.

As far as the generated password is concerned. If one needs to be set to something more secure while creating the account. The -Password flag can be used to do so.

Below is the expected output for creating the new user in Microsoft 365 when it’s successful. If there are any errors, troubleshooting will be necessary. If assistance is required, please shoot me an email and I’ll help.

Password UserPrincipalName DisplayName isLicensed
-------- ----------------- ----------- ----------
$lasdkf  JDoe@example.com  Jane Doe    True

If confirmation is needed. Go to the Microsft 365 portal and review the account configuration.

References

References used to create this article.