← script library

Streamlining M365 User Management with PowerShell

Microsoft 365 & Entra IDJanuary 9, 2025

Dive into this script that assists in managing Microsoft 365 users effortlessly.

powershell
Connect-MgGraph -Scopes "User.Read.All","User.ReadWrite.All"

$users = Get-MgUser -All

$users | Select-Object DisplayName, UserPrincipalName, Mail | Format-Table

New-MgUser -AccountEnabled $true -DisplayName "New User" -MailNickname "newuser" -UserPrincipalName "[email protected]" -PasswordProfile @{ ForceChangePasswordNextSignIn = $true; Password = "SecurePassword123!" }

Disconnect-MgGraph

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.