In Microsoft 365 (M365), users are the individual accounts that people sign in with to access Microsoft services like Outlook, Teams, OneDrive, and SharePoint.
STEP 1: Use a Microsoft Entra DC admin account to connect to your Microsoft 365 tenant
- Open your PowerShell using administrator
- Install the Microsoft Graph PowerShell SDK module. (Install-Module Microsoft.Graph -Scope CurrentUser) some packages would be installed
- Connect to your m365 account (Connect-MgGraph -Scopes “User.ReadWrite.All”)
- Login with your credentials and accept the permissions


Connection to M365 Account successful

STEP 2: Creating a single user
- Define Password Profile. Every new user needs a password at creation, create a password profile:
$PasswordProfile = @{
Password = “Password@123”
ForceChangePasswordNextSignIn = $true}
- Create the User. Use New-MgUser with required parameters:
New-MgUser `
-DisplayName “Adam AKT” `
-GivenName “ADAM” `
-Surname “AKT” `
-UserPrincipalName “adam@yourdomain.com” `
-UsageLocation “US” `
-MailNickname “adam” `
-PasswordProfile $PasswordProfile `
-AccountEnabled:$true
- This creates a user named Adam AKT with an initial password. The user will be forced to change their password on first login.


STEP 3: Creating Multiple Users
- Create a CSV file with the following structure (UserPrincipalName must be unique. Password must meet your organization’s password policy):

- # Import users from CSV
$Users = Import-Csv “C:\Users\FEYI\Desktop\Book5.csv”
- # Create password profile
foreach ($User in $Users) {
$PasswordProfile = @{
Password = $User.Password
ForceChangePasswordNextSignIn = $true
}
- # Create new user
New-MgUser `
-DisplayName $User.DisplayName `
-GivenName $User.GivenName `
-Surname $User.Surname `
-UserPrincipalName $User.UserPrincipalName `
-UsageLocation $User.UsageLocation `
-MailNickname $User.MailNickname `
-PasswordProfile $PasswordProfile `
-AccountEnabled:$true
Write-Host ” Created user: $($User.DisplayName)”
}


Conclusion:
- Single user creation is best for one-off onboarding.
- Bulk user creation via CSV is efficient for mass onboarding.
- This process reduces manual effort and ensures consistency in M365 user management.
