Domain 1 β€” Module 6 of 8 75%
6 of 28 overall
Domain 1: Deploy and Manage a Microsoft 365 Tenant Free ⏱ ~15 min read

Automate with PowerShell: Bulk User Operations

Use Microsoft Graph PowerShell and Microsoft Entra PowerShell for bulk user creation, licence assignment, attribute updates, and operational automation.

Why PowerShell matters at Expert level

Simple explanation

Clicking through 200 user accounts in the admin center is not administration. It’s suffering.

At the Expert level, you’re expected to know PowerShell β€” not because the exam is a coding test, but because real M365 admins automate repetitive tasks. Microsoft Graph PowerShell and Microsoft Entra PowerShell are the two toolsets you need to know. They handle everything from bulk user creation to licence audits to reporting.

The exam won’t ask you to write complex scripts from memory, but it WILL ask: β€œWhich cmdlet does Dev use to…” or β€œWhat approach is most efficient for…”

The two PowerShell toolsets

Microsoft Graph PowerShell vs Microsoft Entra PowerShell
FeatureMicrosoft Graph PowerShellMicrosoft Entra PowerShell
Module nameMicrosoft.GraphMicrosoft.Entra
ScopeAll Microsoft Graph resources (users, groups, mail, files, devices, etc.)Microsoft Entra ID focused (users, groups, apps, roles, policies)
ReplacesAzure AD PowerShell, MSOnlineSimplifies Graph PowerShell for identity tasks
AuthenticationConnect-MgGraphConnect-Entra
User creation cmdletNew-MgUserNew-EntraUser
Best forBroad M365 management and automationIdentity-focused operations
Exam relevancePrimary module for bulk operationsKnow it exists and when to prefer it
Exam tip: Deprecated modules

The exam may reference older module names. Key deprecations:

  • MSOnline (Connect-MsolService, Set-MsolUser) β€” deprecated, replaced by Graph PowerShell
  • Azure AD PowerShell (Connect-AzureAD, New-AzureADUser) β€” deprecated, replaced by Graph/Entra PowerShell

If the exam asks about the β€œrecommended” or β€œcurrent” approach, always choose Microsoft Graph PowerShell or Microsoft Entra PowerShell. Never select MSOnline or AzureAD cmdlets unless the question specifically asks about legacy compatibility.

Common bulk operations

Connecting and authenticating

Before any operations, connect to Microsoft Graph:

Connect-MgGraph -Scopes "User.ReadWrite.All","Group.ReadWrite.All"

This triggers an interactive sign-in and requests the specified permissions. For automated scripts, use a service principal with certificate authentication.

Bulk user creation from CSV

Dev’s typical workflow for onboarding a new client’s 200 users:

  1. Prepare the CSV β€” columns: DisplayName, UserPrincipalName, Password, UsageLocation, Department
  2. Import and create:
Import-Csv users.csv | ForEach-Object {
    New-MgUser -DisplayName $_.DisplayName `
               -UserPrincipalName $_.UserPrincipalName `
               -PasswordProfile @{ Password = $_.Password; ForceChangePasswordNextSignIn = $true } `
               -UsageLocation $_.UsageLocation `
               -Department $_.Department `
               -AccountEnabled:$true
}
  1. Assign licences β€” using group-based licensing (Module 5) or:
Set-MgUserLicense -UserId "user@domain.com" `
    -AddLicenses @(@{SkuId = "your-sku-id"}) `
    -RemoveLicenses @()

Bulk attribute updates

Update department for 50 users who moved to the new β€œDigital Innovation” team:

Get-MgUser -Filter "department eq 'IT'" -All |
    Where-Object { $_.JobTitle -like '*innovation*' } |
    ForEach-Object {
        Update-MgUser -UserId $_.Id -Department "Digital Innovation"
    }

Licence audit report

Generate a report of all licensed users and their assigned plans:

Get-MgUser -All -Property DisplayName,UserPrincipalName,AssignedLicenses |
    Where-Object { $_.AssignedLicenses.Count -gt 0 } |
    Select-Object DisplayName, UserPrincipalName,
        @{N='Licences';E={($_.AssignedLicenses | ForEach-Object { $_.SkuId }) -join ','}} |
    Export-Csv "licence-report.csv" -NoTypeInformation
Deep dive: Application vs delegated permissions

For automated scripts (scheduled tasks, CI/CD pipelines), use application permissions with a service principal instead of interactive sign-in:

  1. Register an app in Entra > App registrations
  2. Grant application permissions (e.g., User.ReadWrite.All)
  3. Get admin consent β€” application permissions require admin consent
  4. Connect with certificate:
Connect-MgGraph -ClientId "app-id" -TenantId "tenant-id" -CertificateThumbprint "thumbprint"

The exam may ask: β€œDev needs to run a nightly script that updates user attributes without interactive sign-in. What authentication method should he use?” Answer: Application permissions with a certificate-based service principal.

Microsoft Entra PowerShell for identity tasks

The newer Microsoft Entra PowerShell module simplifies common identity operations:

OperationGraph PowerShellEntra PowerShell
Create userNew-MgUserNew-EntraUser
Get userGet-MgUserGet-EntraUser
Update userUpdate-MgUserSet-EntraUser
Get groupGet-MgGroupGet-EntraGroup
Add group memberNew-MgGroupMemberAdd-EntraGroupMember

The Entra module uses familiar verb-noun patterns that align more closely with traditional PowerShell conventions, making it easier for admins already comfortable with PowerShell.

Key concepts to remember

Question

What has replaced the deprecated Azure AD PowerShell and MSOnline modules?

Click or press Enter to reveal answer

Answer

Microsoft Graph PowerShell (Microsoft.Graph) for broad M365 management, and Microsoft Entra PowerShell (Microsoft.Entra) for identity-focused operations. Both authenticate through Microsoft Graph and use modern authentication (OAuth 2.0).

Click to flip back

Question

What is the difference between delegated and application permissions in Microsoft Graph?

Click or press Enter to reveal answer

Answer

Delegated permissions act on behalf of a signed-in user (interactive sign-in required). Application permissions act as the app itself without a signed-in user (for automated scripts). Application permissions require admin consent and are more powerful β€” they bypass user context.

Click to flip back

Question

What property must be included when bulk-creating users if you plan to assign licences?

Click or press Enter to reveal answer

Answer

UsageLocation β€” it's required for licence assignment and must be set during user creation in the CSV or PowerShell script. Without it, user creation succeeds but licence assignment fails.

Click to flip back

Knowledge check

Knowledge Check

Dev needs to run a nightly automated script that disables user accounts for employees flagged by HR as terminated. The script runs from a server with no interactive sign-in. Which authentication method should Dev use?

Knowledge Check

Priya needs to generate a report showing all users who have an M365 E5 licence but haven't signed in for 90 days. Which approach is most efficient?


Next up: Roles, Role Groups and Workload Permissions β€” because not every admin should have Global Admin powers.