To create a new user account on Office 365 using PowerShell, you will need to use the New-MsolUser cmdlet. This cmdlet is part of the Azure Active Directory PowerShell for Graph module, which you can install from the PowerShell Gallery.
Before you can use the New-MsolUser cmdlet, you will need to connect to Azure AD using Connect-MsolService and provide your Office 365 global administrator credentials.
Here is an example of how you can use the New-MsolUser cmdlet to create a new user account:
Import-Module AzureAD Connect-MsolService $user = New-MsolUser -DisplayName "John Doe" -UserPrincipalName "[email protected]" -Password (ConvertTo-SecureString -String "P@ssw0rd" -AsPlainText -Force) -StrongPasswordRequired $true
This will create a new user account with the display name “John Doe” and the user principal name “[email protected]”. The password for the account will be “P@ssw0rd” and the StrongPasswordRequired parameter will ensure that the password meets the complexity requirements for Office 365.
You can also use other parameters of the New-MsolUser cmdlet to specify additional details for the user account, such as the first and last name, the usage location, and the department.
For more information about the New-MsolUser cmdlet and the available parameters, you can refer to the Microsoft documentation: