How To Create an Office 365 User With PowerShell

In this blog post, I will show you how you can create an Office 365 using PowerShell without using the console and automate this process.

Azure Active Directory

When it comes to Office 365 user management, Azure Active Directory is the identity platform the Office 365 uses.

Azure Active Directory is the cloud version of Windows Server Active Directory.

Office 365 PowerShell

Not many know it but Office 365 doesn’t have a PowerShell module of its own,  rather each Office 365 service has its own PowerShell module and in our case, we will use the Azure Active Directory module to create an Office 365 user.

Install Azure AD

The first step in creating an Office 365 user will be to install the Azure AD PowerShell module, and you can do it by running the following cmdlet on your Windows 10 machine.

install-module azuread

Connect

After installing the Azure AD module let’s connect to Azure AD using the following cmdlet.

connect-azuread

Create User

to create an Office 365, I will use the following three cmdlets.

The first and second line will set the password (you will be asked to provide one) and the last and third line will create a user called Bob King.

$Pass = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$Pass.Password = read-host "Type password"
New-AzureADUser -DisplayName "Bob King" -PasswordProfile $Pass -UserPrincipalName "bob.king@emailaddress.local" -AccountEnabled $true -MailNickName "BobKing"

Processing…
Success! You're on the list.

Posted

in

,

by