Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitSetting up new employees in Microsoft 365 can be streamlined using Microsoft Graph PowerShell. This guide walks you through the step-by-step onboarding process, from user creation to assigning roles, using tested cmdlets.
Start by connecting to Microsoft Graph with the necessary permissions:
Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All", "Group.ReadWrite.All"
Provision the user with a secure, ready-to-use account:
New-MgUser -DisplayName "Jane Kumar" `
-UserPrincipalName "jane.kumar@yourdomain.com" `
-MailNickname "janekumar" `
-AccountEnabled `
-PasswordProfile @{ ForceChangePasswordNextSignIn = $true; Password = "StrongP@ssw0rd!" }
✅ This creates an active user account and enforces a password change at first login.
Enable a ccess to Microsoft 365 services by assigning a license:
Set-MgUserLicense -UserId "jane.kumar@yourdomain.com" -AddLicenses @(@{SkuId="license-sku-id"}) -RemoveLicenses @()
🔑 Not sure what SkuId to use? Run:
Get-MgSubscribedSku | select id, skupartnumber
This lists all available license types (along with their SKU IDs) in your tenant. Note: RemoveLicenses @() should be included for the command to work (even though you may not be removing any licenses).
Ensure the user has proper access and collaboration rights:
New-MgGroupMember -GroupId "group-id" -DirectoryObjectId "user-object-id"
📌 Use:
Update organizational metadata:
Update-MgUser -UserId "jane.kumar@7xh7fj.onmicrosoft.com" `
-Department "Sales" `
-JobTitle "Territory Manager"
This helps with internal org charts, policies, and access controls.
Grant admin privileges only if needed:
$roleId = (Get-MgDirectoryRole -Filter "displayName eq 'Global Administrator'").Id
$body = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/2d6a3dc5-36af-494b-aebd-e2dd179077b2"
}
New-MgDirectoryRoleMemberByRef -DirectoryRoleId $roleId -BodyParameter $body
🛡️ Only assign roles like Global Admin or Exchange Admin to trusted individuals—these roles have high privileges.
After license assignment, mailboxes are provisioned automatically.
➡️ For advanced configurations, use Exchange Online PowerShell as Graph PowerShell doesn’t manage mailbox settings directly.
Confirm the user is fully onboarded:
Get-MgUser -UserId "jane.kumar@yourdomain.com"
📊 You can also check in the Microsoft 365 Admin Center for the newly created user details (Users >> Active Users) or using Entra ID Admin Center (Entra ID >> All Users).
With just a few Graph PowerShell commands, you can automate and standardize the Microsoft 365 onboarding process. You can wrap all this into a PowerShell function or workflow script that takes parameters like name, department etc., and automates user onboarding. This ensures consistency, security, and speed, especially in growing organizations.
© m365corner.com. All Rights Reserved. Design by HTML Codex