Set-EntraUserPasswordProfile
設定使用者的密碼。
語法
Default (預設值)
Set-EntraUserPasswordProfile
[-ForceChangePasswordNextSignIn]
[-ForceChangePasswordNextSignInWithMfa]
-UserId <String>
-Password <SecureString>
[<CommonParameters>]
Description
帶有別名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。