Set-EntraUserPasswordProfile

设置用户的密码。

语法

Default (默认值)

Set-EntraUserPasswordProfile

    [-ForceChangePasswordNextSignIn]
    [-ForceChangePasswordNextSignInWithMfa]
    -UserId <String>
    -Password <SecureString>
    [<CommonParameters>]

说明

Set-EntraUserPasswordProfile别名的 Set-EntraUserPassword cmdlet 为Microsoft Entra ID中的用户设置密码。

任何用户都可以在不具有任何管理员角色的情况下更新其密码。

示例

示例 1:设置用户的密码

Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword = '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraUserPasswordProfile -UserId 'SawyerM@contoso.com' -Password $securePassword

此命令设置指定的用户密码。

  • -UserId参数指定Microsoft Entra ID中用户的 ID。
  • -Password 参数指定要设置的密码。

示例 2:使用 ForceChangePasswordNextSignInWithMfa 参数设置用户的密码

Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword= '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraUserPasswordProfile -UserId 'SawyerM@contoso.com' -Password $securePassword -ForceChangePasswordNextSignInWithMfa

此命令使用 ForceChangePasswordNextSignInWithMfa 参数设置指定的用户密码。

  • -UserId参数指定Microsoft Entra ID中用户的 ID。
  • -Password 参数指定要设置的密码。
  • -ForceChangePasswordNextSignInWithMfa 参数强制用户更改其密码。

示例 3:使用 ForceChangePasswordNextSignIn 参数设置用户的密码

connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword= '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraUserPasswordProfile -UserId 'SawyerM@contoso.com' -Password $securePassword -ForceChangePasswordNextSignIn

此命令使用 ForceChangePasswordNextSignIn 参数设置指定的用户密码。

  • -UserId参数指定Microsoft Entra ID中用户的 ID。
  • -Password 参数指定要设置的密码。
  • -ForceChangePasswordNextSignIn 参数强制用户在下次登录期间更改其密码。

参数

-ForceChangePasswordNextSignIn

强制用户在下次登录期间更改其密码。

参数属性

类型:System.Management.Automation.SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ForceChangePasswordNextSignInWithMfa

如果设置为 true,则强制用户更改其密码。

参数属性

类型:System.Management.Automation.SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Password

指定密码。

参数属性

类型:System.SecureString
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

-UserId

指定用户的 ID。

参数属性

类型:System.String
默认值:None
支持通配符:False
不显示:False
别名:对象标识符 (ObjectId), UPN, Identity, UserPrincipalName

参数集

(All)
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):True
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters