Set-MsolUser
Modifies a user in Azure Active Directory.
Syntax
Set-MsolUser
[-ImmutableId <String>]
[-ObjectId <Guid>]
[-UserPrincipalName <String>]
[-BlockCredential <Boolean>]
[-City <String>]
[-Country <String>]
[-Department <String>]
[-DisplayName <String>]
[-Fax <String>]
[-FirstName <String>]
[-LastName <String>]
[-LastPasswordChangeTimestamp <DateTime>]
[-MobilePhone <String>]
[-Office <String>]
[-PasswordNeverExpires <Boolean>]
[-PhoneNumber <String>]
[-PostalCode <String>]
[-PreferredDataLocation <String>]
[-PreferredLanguage <String>]
[-SoftDeletionTimestamp <DateTime>]
[-State <String>]
[-StreetAddress <String>]
[-StrongPasswordRequired <Boolean>]
[-Title <String>]
[-UsageLocation <String>]
[-AlternateEmailAddresses <String[]>]
[-StrongAuthenticationMethods <StrongAuthenticationMethod[]>]
[-AlternateMobilePhones <String[]>]
[-StrongAuthenticationRequirements <StrongAuthenticationRequirement[]>]
[-StsRefreshTokensValidFrom <DateTime>]
[-UserType <UserType>]
[-TenantId <Guid>]
[<CommonParameters>]
Description
The Set-MsolUser cmdlet modifies a user object.
Use this cmdlet only for updates to basic properties. Update the licenses, password, and User Principal Name for a user by using the Set-MsolUserLicense, Set-MsolUserPassword and Set-MsolUserPrincipalName cmdlets.
Examples
Example 1: Block credential for a user
PS C:\> Set-MsolUser -UserPrincipalName "davidchew@contoso.com" -BlockCredential $True
This command sets block credential to $True for a user, which blocks them from being able to sign in. This cannot be done for a synced user.
Example 2: Update display name
PS C:\> Set-MsolUser -UserPrincipalName "davidchew@contoso.com" -DisplayName "David Chew" -Title "Manager" -Department "Finance"
This command updates the display name for the specified user.
Example 3: Set the location of a user
PS C:\> Set-MsolUser -UserPrincipalName "davidchew@contoso.com" -UsageLocation "CA"
This command sets the location country of a user. The country must be a two-letter ISO code. This can be set for synced users as well as managed users.
Example 4: Set the preferred data location
PS C:\> Set-MsolUser -UserPrincipalName "davidchew@contoso.com" -PreferredDataLocation "EUR"
This command sets the preferred data location property of a user whose user principal name is davidchew@contoso.com to EUR.
Parameters
Specifies alternate email addresses for the user.
| Type: | String[] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies alternate mobile phone numbers for the user.
| Type: | String[] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies whether the user is not able to log on using their user ID.
| Type: | Boolean |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the city of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the country or region of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the department of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the display name of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the fax number of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the first name of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the immutable ID of the federated identity of the user. This should be omitted for users with standard identities.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the last name of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies a time when the password was last changed.
| Type: | DateTime |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the mobile phone number of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the unique object ID of the user.
| Type: | Guid |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the location of the office of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies whether the user password expires periodically.
| Type: | Boolean |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the phone number of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the postal code of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the preferred data location for the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the preferred language of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies a time for soft deletion.
| Type: | DateTime |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the state or province where the user is located.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the street address of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies an array of strong authentication methods.
| Type: | StrongAuthenticationMethod[] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies an array of strong authentication requirements.
| Type: | StrongAuthenticationRequirement[] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies whether to require a strong password for the user.
| Type: | Boolean |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies a StsRefreshTokensValidFrom value.
| Type: | DateTime |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the unique ID of the tenant on which to perform the operation. The default value is the tenant of the current user. This parameter applies only to partner users.
| Type: | Guid |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the title of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the location of the user where services are consumed. Specify a two-letter country code.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the user ID of the user.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Specifies the user type.
| Type: | UserType |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |