With the deprecation of the AzureAD module, administrators must transition their scripts to the Microsoft Graph PowerShell SDK. One commonly used cmdlet that now requires upgrading is Set-AzureADUser, which was used to update Microsoft 365 user properties. The modern alternative is Update-MgUser.
This guide will help you migrate to Update-MgUser by showing what changed, what to use now, and best practices for keeping your scripts future-proof and scalable.
The Set-AzureADUser cmdlet allowed you to update various user attributes using straightforward parameter-based syntax.
Set-AzureADUser -ObjectId "john.doe@contoso.com" `
-DisplayName "Johnathan Doe" `
-JobTitle "Senior Developer"
Set-AzureADUser -ObjectId "jane.smith@contoso.com" -AccountEnabled $true
Set-AzureADUser -ObjectId "alex.wilson@yourdomain.com" `
-City "Seattle" `
-Country "United States"
While these were effective, they depended on a now-deprecated module and offered limited extensibility.
In Microsoft Graph PowerShell, use Update-MgUser for all user property modifications. While some properties can still be updated via named parameters, the recommended and flexible method is to use -BodyParameter with a hashtable, especially for bulk updates or nested attributes.
Update-MgUser -UserId "john.doe@contoso.com" `
-DisplayName "Johnathan Doe" `
-JobTitle "Senior Developer"
Update-MgUser -UserId "jane.smith@contoso.com" -AccountEnabled $true
Update-MgUser -UserId "alex.wilson@yourdomain.com" -BodyParameter @{
city = "Seattle"
country = "United States"
}
Recommendation: Use -BodyParameter for all updates involving multiple fields, uncommon attributes, or automation scenarios. It ensures cleaner, more reliable code and is essential for bulk operations.
Old (Set-AzureADUser) | New (Update-MgUser) |
Uses -ObjectId | Uses -UserId (UPN or GUID) |
Accepts named parameters for all | Can use named params, but -BodyParameter preferred |
Part of AzureAD module | Part of Microsoft.Graph.Users module |
Limited extensibility | Fully Graph-compliant and extensible |
No structured body input | Supports powerful hashtable input |
Migrating from Set-AzureADUser to Update-MgUser is a necessary step to align with Microsoft’s modern identity platform. Whether you're updating job titles, enabling accounts, or running mass updates via CSV, Update-MgUser provides the flexibility, structure, and compatibility required for future-ready scripting.
👉 Use -BodyParameter whenever possible for bulk or advanced updates.
© Your Site Name. All Rights Reserved. Design by HTML Codex