Quick answer: Set-User changes a user's directory details in Exchange: display name, title, department, manager, phone numbers and address. It has no mail settings. For mailbox or mail user settings, use Set-Mailbox or Set-MailUser.
Set-User -Identity "jill@contoso.com" -DisplayName "Jill Frank" -Title "Sales Manager"
The cmdlet works in Exchange Online and in on-premises Exchange. A few parameters work in only one of them (table below). Source: Set-User on Microsoft Learn.
What does Set-User change?
User details that appear in the address book and directory, for example names, job details, phone numbers and the office address. It does not change mailbox size, forwarding or email addresses. Those belong to Set-Mailbox (mailboxes) or Set-MailUser (mail users).
-Identity accepts any value that uniquely identifies the user, such as the name, user principal name (UPN), distinguished name, canonical DN or GUID.
How do I connect?
- Exchange Online: run
Connect-ExchangeOnlinefirst. - On-premises: open the Exchange Management Shell.
How do I change a user's name?
Set-User -Identity "jill@contoso.com" -DisplayName "Jill Frank" -FirstName "Jill" -LastName "Frank"
-DisplayName allows up to 256 characters. -Name, the user's unique name, allows up to 64.
How do I set job title, department and manager?
Set-User -Identity "jill@contoso.com" -Title "Sales Manager" -Department "Sales" -Company "Contoso" -Manager "alex@contoso.com"
How do I update phone numbers and office address?
Set-User -Identity "jill@contoso.com" -Phone "+1 425 555 0100" -MobilePhone "+1 425 555 0199" -Office "Building 34"
Set-User -Identity "jill@contoso.com" -StreetAddress "1 Main St" -City "Redmond" -StateOrProvince "WA" -PostalCode "98052" -CountryOrRegion "US"
-CountryOrRegion takes a two-letter ISO 3166-1 code (for example US or AU) or the country's friendly name.
In Exchange Online, Microsoft Graph PowerShell's Update-MgUser can also set business and mobile phone numbers.
How do I update many users from a CSV file?
Make a CSV with an Identity column and one column per field, then pipe it in:
Import-Csv .\users.csv | ForEach-Object {
Set-User -Identity $_.Identity -Title $_.Title -Department $_.Department
}
How do I make a user change their password?
Set-User -Identity "jill@contoso.com" -ResetPasswordOnNextLogon $true
The user must change their password at the next sign-in. $false is the default.
How do I block a user from Exchange PowerShell?
In Exchange Online:
Set-User -Identity "jill@contoso.com" -EXOModuleEnabled $false
The user can no longer connect to Exchange Online PowerShell. That access is also needed to open the Exchange admin center. On-premises, use -RemotePowerShellEnabled $false; in the cloud, that parameter is being deprecated in favor of -EXOModuleEnabled.
Which parameters work where?
| Parameter | Where | What it does |
|---|---|---|
-DisplayName, -FirstName, -LastName, -Name |
Both | Names |
-Title, -Department, -Company, -Manager |
Both | Job details |
-Phone, -MobilePhone, -HomePhone, -Office |
Both | Contact details |
-StreetAddress, -City, -StateOrProvince, -PostalCode, -CountryOrRegion |
Both | Address |
-Notes |
Both | Free-text notes |
-ResetPasswordOnNextLogon |
Both | Force a password change |
-AuthenticationPolicy |
Exchange Online, Exchange 2019 and later | Apply or remove ($null) an authentication policy |
-EXOModuleEnabled |
Exchange Online | Exchange Online PowerShell access |
-VIP |
Exchange Online | Mark a priority account |
-PermanentlyClearPreviousMailboxInfo |
Exchange Online | Clear old Exchange Online mailbox attributes |
-UserPrincipalName, -SamAccountName |
On-premises only | Sign-in names |
-LinkedMasterAccount |
On-premises | Unlink a linked mailbox ($null) |
What does -PermanentlyClearPreviousMailboxInfo do?
Set-User -Identity "jill@contoso.com" -PermanentlyClearPreviousMailboxInfo
It clears a user's Exchange Online mailbox attributes. This can be needed when moving mailboxes or changing licenses between on-premises Exchange and Microsoft 365. After it runs, you can't reconnect to the old mailbox or recover its content.
How do I unlink a linked mailbox?
On-premises:
Set-User -Identity "kweku@contoso.com" -LinkedMasterAccount $null
This converts the linked mailbox to a user mailbox. It removes every permission on the mailbox, including Send As, Full Access, and folder and calendar delegation.
What permissions do I need?
You need roles that include Set-User and the parameters you use. Some parameters are hidden if your roles don't cover them. See Find the permissions required to run any Exchange cmdlet.
Troubleshooting
| Problem | Fix |
|---|---|
| A parameter isn't recognized | Your roles don't include it, or it doesn't exist in your environment. Check the table above |
-UserPrincipalName or -SamAccountName missing in Exchange Online |
Both are on-premises only |
| Can't change email addresses or forwarding | Use Set-Mailbox or Set-MailUser; Set-User has no mail settings |
-RemotePowerShellEnabled doesn't change cloud access |
Use -EXOModuleEnabled in Exchange Online |
| Name rejected | -Name allows 64 characters, -DisplayName 256 |
Summary
Set-Userchanges directory details: names, job details, phone numbers, address.- Mail settings belong to
Set-MailboxorSet-MailUser. - UPN and SAM account name changes are on-premises only.
-PermanentlyClearPreviousMailboxInfocan't be undone.
Related: Get-Mailbox, Set-CalendarProcessing.
Meeting Room 365 turns any iPad or Android tablet into a room display for Exchange and Microsoft 365 calendars. See the features or pricing: $9 a display a month.