Set-EntraUserPassword
Sets the password of a user.
Syntax
Default (Default)
Set-EntraUserPassword
[-ForceChangePasswordNextLogin <Boolean>]
[-EnforceChangePasswordPolicy <Boolean>]
-UserId <String>
-Password <SecureString>
[<CommonParameters>]
Description
The Set-EntraUserPassword
cmdlet sets the password for a user in Microsoft Entra ID.
Any user can update their password without belonging to any administrator role.
Examples
Example 1: Set a user's password
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword = '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraUserPassword -UserId 'SawyerM@contoso.com' -Password $securePassword
This command sets the specified user's password.
-UserId
parameter specifies the ID of a user in Microsoft Entra ID.-Password
parameter specifies the password to set.
Example 2: Set a user's password with EnforceChangePasswordPolicy parameter
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword= '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraUserPassword -UserId 'SawyerM@contoso.com' -Password $securePassword -EnforceChangePasswordPolicy $True
This command sets the specified user's password with EnforceChangePasswordPolicy parameter.
-UserId
parameter specifies the ID of a user in Microsoft Entra ID.-Password
parameter specifies the password to set.-EnforceChangePasswordPolicy
parameter force the user to change their password, if set to true.
Example 3: Set a user's password with ForceChangePasswordNextLogin parameter
connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword= '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraUserPassword -UserId 'SawyerM@contoso.com' -Password $securePassword -ForceChangePasswordNextLogin $True
This command sets the specified user's password with ForceChangePasswordNextLogin parameter.
-UserId
parameter specifies the ID of a user in Microsoft Entra ID.-Password
parameter specifies the password to set.-ForceChangePasswordNextLogin
parameter forces a user to change their password during their next log in.
Parameters
-EnforceChangePasswordPolicy
If set to true, force the user to change their password.
Parameter properties
Type: | System.Boolean |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-ForceChangePasswordNextLogin
Forces a user to change their password during their next sign in.
Parameter properties
Type: | System.Boolean |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Password
Specifies the password.
Parameter properties
Type: | System.SecureString |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-UserId
Specifies the ID of a user.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | ObjectId, UPN, Identity, UserPrincipalName |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.