Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitUpdating user details is one of the most common and essential tasks for Microsoft 365 administrators. Whether you're correcting display names, updating phone numbers, changing job titles, or adjusting office locations — the Update-MgUser cmdlet from Microsoft Graph PowerShell makes it easy and efficient.
This article covers 7 practical and beginner-friendly scripts using Update-MgUser, each designed to help you understand how to update user attributes safely and effectively.
Before running any of the scripts below, install and connect to Microsoft Graph PowerShell:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.ReadWrite.All"
Once connected, you're ready to start updating users in your tenant.
Update-MgUser -UserId "john.doe@contoso.com" -DisplayName "Johnathan Doe" -JobTitle "Senior Developer"
Explanation:
This script updates both the display name and job title for john.doe@contoso.com. Useful during promotions, name corrections, or profile standardization.
Update-MgUser -UserId "jane.smith@contoso.com" -AccountEnabled $true
Explanation:
Sets jane.smith@contoso.com as an active user. This is commonly used when reactivating accounts for returning employees or resolving accidental disables.
Update-MgUser -UserId "alex.wang@contoso.com" -MobilePhone "+1 555 555 5555" -OfficeLocation "Building 4" -PreferredLanguage "en-US"
Explanation:
Updates several fields at once — mobile number, office location, and preferred language. This is ideal for onboarding updates or mass profile corrections.
Update-MgUser -UserId "mary.jones@contoso.com" -OtherMails @("mary.jones@otherdomain.com")
Explanation:
Adds an alternate email address to the OtherMails attribute. Often used when users have external aliases or when migrating from another mail system.
Update-MgUser -UserId "old.username@contoso.com" -UserPrincipalName "new.username@contoso.com"
Explanation:
Changes the UPN (login name). This is common during name changes, rebranding, or converting old naming conventions.
Useful for keeping physical location details accurate, especially for compliance or HR-driven updates.
Update-MgUser -UserId "alex.wilson@yourdomain.com" -BodyParameter @{
city = "Seattle"
country = "United States"
}
Explanation:
Updates the city and country fields using the -BodyParameter hashtable format. Great for multi-location organizations maintaining updated directory data.
This example updates the office location for an employee.
Update-MgUser -UserId "alex.johnson@yourdomain.com" -BodyParameter @{
officeLocation = "HQ-Block B"
}
Explanation:
Updates officeLocation using -BodyParameter. Often used when employees move desks, floors, or facilities.
| Error | Cause | Solution |
| Insufficient privileges to complete the operation | Missing required scopes | Reconnect using Connect-MgGraph -Scopes "User.ReadWrite.All" |
| Property is read-only | Trying to modify a system-managed property | Avoid editing unsupported attributes |
| Request_BadRequest | Invalid parameter value | Double-check attribute spelling and supported formats |
| User not found | Incorrect UPN or object ID | Verify identity using Get-MgUser |
| DirectoryObjectNotFound | Trying to update a deleted or unlicensed account | Restore user or assign required licenses |
The Update-MgUser cmdlet is a powerful and flexible tool for updating Microsoft 365 user profiles. Whether you’re modifying display names, locations, languages, or enabling accounts, these examples give you a strong foundation for real-world administration tasks.
As you grow more comfortable, you can combine multiple updates into automated workflows to simplify user management even further.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex