Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .config/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"file": "test\\Entra\\Users\\Update-EntraUserFromFederated.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\Entra\\Users\\Set-EntraUserPasswordProfile.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\EntraBeta\\Users\\Set-EntraBetaSignedInUserPassword.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
Expand All @@ -45,6 +49,10 @@
"file": "test\\EntraBeta\\Users\\New-EntraBetaUser.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\EntraBeta\\Users\\Set-EntraBetaUserPasswordProfile.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\Entra\\CertificateBasedAuthentication\\Get-EntraUserCertificateUserIdsFromCertificate.Tests.ps1",
"_justification": "Unit test file has a sample certificate with only public keys used in mocking."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Enable-EntraAzureADAlias {
Set-Alias -Name Get-AzureADServiceAppRoleAssignedTo -Value Get-EntraServicePrincipalAppRoleAssignedTo -Scope Global -Force
Set-Alias -Name Get-AzureADMSNamedLocationPolicy -Value Get-EntraNamedLocationPolicy -Scope Global -Force
Set-Alias -Name Get-AzureADContact -Value Get-EntraContact -Scope Global -Force
Set-Alias -Name Set-AzureADUserPassword -Value Set-EntraUserPassword -Scope Global -Force
Set-Alias -Name Set-AzureADUserPassword -Value Set-EntraUserPasswordProfile -Scope Global -Force
Set-Alias -Name Get-AzureADApplicationKeyCredential -Value Get-EntraApplicationKeyCredential -Scope Global -Force
Set-Alias -Name Get-AzureADContactDirectReport -Value Get-EntraContactDirectReport -Scope Global -Force
Set-Alias -Name New-AzureADApplicationExtensionProperty -Value New-EntraApplicationExtensionProperty -Scope Global -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
function Set-EntraSignedInUserPassword {
[Alias("Update-EntraSignedInUserPassword")]
[CmdletBinding(DefaultParameterSetName = 'Default')]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies the new password for the signed-in user.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
function Set-EntraUserPassword {
function Set-EntraUserPasswordProfile {
[CmdletBinding(DefaultParameterSetName = 'Default')]
param (
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies whether the user must change their password at next sign-in.")]
[System.Boolean] $ForceChangePasswordNextLogin,
[Parameter(ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $false, HelpMessage = "Specifies whether the user must change their password at next sign-in.")]
[Alias('ForceChangePasswordNextLogin')]
[switch] $ForceChangePasswordNextSignIn,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies the ID of a user (as a UserPrincipalName or ObjectId) in Microsoft Entra ID.")]
[Alias('ObjectId', 'UPN', 'Identity', 'UserPrincipalName')]
Expand All @@ -24,8 +25,9 @@ function Set-EntraUserPassword {
[ValidateNotNullOrEmpty()]
[System.Security.SecureString] $Password,

[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "If set to true, force the user to change their password.")]
[System.Boolean] $EnforceChangePasswordPolicy
[Parameter(ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $false, HelpMessage = "If set, force the user to change their password.")]
[Alias('EnforceChangePasswordPolicy')]
[switch] $ForceChangePasswordNextSignInWithMfa
)

begin {
Expand Down Expand Up @@ -81,16 +83,16 @@ function Set-EntraUserPassword {
if ($null -ne $PSBoundParameters["WarningAction"]) {
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
}
if ($null -ne $PSBoundParameters["ForceChangePasswordNextLogin"]) {
$ForceChangePasswordNextSignIn = $PSBoundParameters["ForceChangePasswordNextLogin"]
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignIn"]) {
$ForceChangePasswordNextSignIn = $true
}
if ($null -ne $PSBoundParameters["EnforceChangePasswordPolicy"]) {
$ForceChangePasswordNextSignInWithMfa = $PSBoundParameters["EnforceChangePasswordPolicy"]
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignInWithMfa"]) {
$ForceChangePasswordNextSignInWithMfa = $true
}

$PasswordProfile = @{}
if ($null -ne $PSBoundParameters["ForceChangePasswordNextLogin"]) { $PasswordProfile["ForceChangePasswordNextSignIn"] = $ForceChangePasswordNextSignIn }
if ($null -ne $PSBoundParameters["EnforceChangePasswordPolicy"]) { $PasswordProfile["ForceChangePasswordNextSignInWithMfa"] = $ForceChangePasswordNextSignInWithMfa }
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignIn"]) { $PasswordProfile["ForceChangePasswordNextSignIn"] = $ForceChangePasswordNextSignIn }
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignInWithMfa"]) { $PasswordProfile["ForceChangePasswordNextSignInWithMfa"] = $ForceChangePasswordNextSignInWithMfa }
if ($null -ne $PSBoundParameters["Password"]) { $PasswordProfile["password"] = $PlainPassword }

Write-Debug("============================ TRANSFORMATIONS ============================")
Expand All @@ -102,3 +104,4 @@ function Set-EntraUserPassword {
}
}

Set-Alias -Name Set-EntraUserPassword -Value Set-EntraUserPasswordProfile -Scope Global -Force
2 changes: 1 addition & 1 deletion module/Entra/config/moduleMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
"Set-EntraUserExtension": "Users",
"Set-EntraUserLicense": "Users",
"Set-EntraUserManager": "Users",
"Set-EntraUserPassword": "Users",
"Set-EntraUserPasswordProfile": "Users",
"Set-EntraUserThumbnailPhoto": "Users",
"Update-EntraOauth2PermissionGrant":"SignIns",
"Set-EntraSignedInUserPassword": "Users",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
function Set-EntraBetaUserPassword {
function Set-EntraBetaUserPasswordProfile {
[CmdletBinding(DefaultParameterSetName = 'Default')]
param (
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies whether the user must change their password at next sign-in.")]
[System.Boolean] $ForceChangePasswordNextLogin,
[Parameter(ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $false, HelpMessage = "Specifies whether the user must change their password at next sign-in.")]
[Alias('ForceChangePasswordNextLogin')]
[switch] $ForceChangePasswordNextSignIn,

[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "If set to true, force the user to change their password.")]
[System.Boolean] $EnforceChangePasswordPolicy,
[Parameter(ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $false, HelpMessage = "If set, force the user to change their password.")]
[Alias('EnforceChangePasswordPolicy')]
[switch] $ForceChangePasswordNextSignInWithMfa,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies the ID of a user (as a UserPrincipalName or ObjectId) in Microsoft Entra ID.")]
[Alias('ObjectId', 'UPN', 'Identity', 'UserPrincipalName')]
Expand Down Expand Up @@ -82,16 +84,16 @@ function Set-EntraBetaUserPassword {
if ($null -ne $PSBoundParameters["WarningAction"]) {
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
}
if ($null -ne $PSBoundParameters["ForceChangePasswordNextLogin"]) {
$ForceChangePasswordNextSignIn = $PSBoundParameters["ForceChangePasswordNextLogin"]
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignIn"]) {
$ForceChangePasswordNextSignIn = $true
}
if ($null -ne $PSBoundParameters["EnforceChangePasswordPolicy"]) {
$EnforceChangePasswordPolicy = $PSBoundParameters["EnforceChangePasswordPolicy"]
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignInWithMfa"]) {
$ForceChangePasswordNextSignInWithMfa = $true
}

$PasswordProfile = @{}
if ($null -ne $PSBoundParameters["ForceChangePasswordNextLogin"]) { $PasswordProfile["ForceChangePasswordNextSignIn"] = $ForceChangePasswordNextSignIn }
if ($null -ne $PSBoundParameters["EnforceChangePasswordPolicy"]) { $PasswordProfile["ForceChangePasswordNextSignInWithMfa"] = $ForceChangePasswordNextSignInWithMfa }
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignIn"]) { $PasswordProfile["ForceChangePasswordNextSignIn"] = $ForceChangePasswordNextSignIn }
if ($null -ne $PSBoundParameters["ForceChangePasswordNextSignInWithMfa"]) { $PasswordProfile["ForceChangePasswordNextSignInWithMfa"] = $ForceChangePasswordNextSignInWithMfa }
if ($null -ne $PSBoundParameters["Password"]) { $PasswordProfile["password"] = $PlainPassword }

Write-Debug("============================ TRANSFORMATIONS ============================")
Expand All @@ -103,3 +105,4 @@ function Set-EntraBetaUserPassword {
}
}

Set-Alias -Name Set-EntraBetaUserPassword -Value Set-EntraBetaUserPasswordProfile -Scope Global -Force
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function Enable-EntraAzureADAlias {
Set-Alias -Name New-AzureADMSPermissionGrantPolicy -Value New-EntraBetaPermissionGrantPolicy -Scope Global -Force
Set-Alias -Name New-AzureADMSApplication -Value New-EntraBetaApplication -Scope Global -Force
Set-Alias -Name Get-AzureADTenantDetail -Value Get-EntraBetaTenantDetail -Scope Global -Force
Set-Alias -Name Set-AzureADUserPassword -Value Set-EntraBetaUserPassword -Scope Global -Force
Set-Alias -Name Set-AzureADUserPassword -Value Set-EntraBetaUserPasswordProfile -Scope Global -Force
Set-Alias -Name Get-AzureADPolicyAppliedObject -Value Get-EntraBetaPolicyAppliedObject -Scope Global -Force
Set-Alias -Name Get-AzureADServiceAppRoleAssignedTo -Value Get-EntraBetaServicePrincipalAppRoleAssignedTo -Scope Global -Force
Set-Alias -Name Get-AzureADMSGroupLifecyclePolicy -Value Get-EntraBetaGroupLifecyclePolicy -Scope Global -Force
Expand Down
2 changes: 1 addition & 1 deletion module/EntraBeta/config/moduleMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Set-EntraBetaUserExtension": "Users",
"Set-EntraBetaUserLicense": "Users",
"Set-EntraBetaUserManager": "Users",
"Set-EntraBetaUserPassword": "Users",
"Set-EntraBetaUserPasswordProfile": "Users",
"Set-EntraBetaUserThumbnailPhoto": "Users",
"Set-EntraBetaSignedInUserPassword": "Users",
"Get-EntraBetaGroup": "Groups",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
author: msewaweru
description: This article provides details on the Set-EntraBetaUserPassword command.
description: This article provides details on the Set-EntraBetaUserPasswordProfile command.
external help file: Microsoft.Entra.Beta.Users-Help.xml
Locale: en-US
manager: mwongerapk
Expand All @@ -9,12 +9,12 @@ ms.author: eunicewaweru
ms.date: 07/24/2024
ms.reviewer: stevemutungi
ms.topic: reference
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra.Beta/Set-EntraBetaUserPassword
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra.Beta/Set-EntraBetaUserPasswordProfile
schema: 2.0.0
title: Set-EntraBetaUserPassword
title: Set-EntraBetaUserPasswordProfile
---

# Set-EntraBetaUserPassword
# Set-EntraBetaUserPasswordProfile

## SYNOPSIS

Expand All @@ -23,17 +23,17 @@ Sets the password of a user.
## SYNTAX

```powershell
Set-EntraBetaUserPassword
Set-EntraBetaUserPasswordProfile
-UserId <String>
-Password <SecureString>
[-ForceChangePasswordNextLogin <Boolean>]
[-EnforceChangePasswordPolicy <Boolean>]
[-ForceChangePasswordNextSignIn]
[-ForceChangePasswordNextSignInWithMfa]
[<CommonParameters>]
```

## DESCRIPTION

The `Set-EntraBetaUserPassword` cmdlet sets the password for a user in Microsoft Entra ID.
The `Set-EntraBetaUserPasswordProfile` cmdlet with alias `Set-EntraBetaUserPassword` sets the password for a user in Microsoft Entra ID.

Any user can update their password without belonging to any administrator role.

Expand All @@ -45,75 +45,75 @@ Any user can update their password without belonging to any administrator role.
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$newPassword = '<strong-password>'
$securePassword = ConvertTo-SecureString $newPassword -AsPlainText -Force
Set-EntraBetaUserPassword -UserId 'SawyerM@contoso.com' -Password $securePassword
Set-EntraBetaUserPasswordProfile -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
### Example 2: Set a user's password with ForceChangePasswordNextSignInWithMfa parameter

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

This command sets the specified user's password with EnforceChangePasswordPolicy parameter.
This command sets the specified user's password with ForceChangePasswordNextSignInWithMfa 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.
- `-ForceChangePasswordNextSignInWithMfa` parameter force the user to change their password.

### Example 3: Set a user's password with ForceChangePasswordNextLogin parameter
### Example 3: Set a user's password with ForceChangePasswordNextSignIn parameter

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

This command sets the specified user's password with ForceChangePasswordNextLogin parameter.
This command sets the specified user's password with ForceChangePasswordNextSignIn 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.
- `-ForceChangePasswordNextSignIn` parameter forces a user to change their password during their next log in.

## PARAMETERS

### -EnforceChangePasswordPolicy
### -ForceChangePasswordNextSignInWithMfa

If set to true, force the user to change their password.

```yaml
Type: System.Boolean
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept pipeline input: False
Accept wildcard characters: False
```

### -ForceChangePasswordNextLogin
### -ForceChangePasswordNextSignIn

Forces a user to change their password during their next sign in.

```yaml
Type: System.Boolean
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand Down
Loading