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
4 changes: 2 additions & 2 deletions .config/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\Entra\\Users\\Update-EntraSignedInUserPassword.Tests.ps1",
"file": "test\\Entra\\Users\\Set-EntraSignedInUserPassword.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\Entra\\Users\\Update-EntraUserFromFederated.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
"file": "test\\EntraBeta\\Users\\Update-EntraBetaSignedInUserPassword.Tests.ps1",
"file": "test\\EntraBeta\\Users\\Set-EntraBetaSignedInUserPassword.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function Enable-EntraAzureADAlias {
Set-Alias -Name Get-AzureADDevice -Value Get-EntraDevice -Scope Global -Force
Set-Alias -Name Get-AzureADObjectByObjectId -Value Get-EntraObjectByObjectId -Scope Global -Force
Set-Alias -Name Remove-AzureADMSApplicationPassword -Value Remove-EntraApplicationPassword -Scope Global -Force
Set-Alias -Name Update-AzureADSignedInUserPassword -Value Update-EntraSignedInUserPassword -Scope Global -Force
Set-Alias -Name Update-AzureADSignedInUserPassword -Value Set-EntraSignedInUserPassword -Scope Global -Force
Set-Alias -Name Set-AzureADMSNamedLocationPolicy -Value Set-EntraNamedLocationPolicy -Scope Global -Force
Set-Alias -Name Get-AzureADMSPermissionGrantPolicy -Value Get-EntraPermissionGrantPolicy -Scope Global -Force
Set-Alias -Name Get-AzureADApplicationServiceEndpoint -Value Get-EntraApplicationServiceEndpoint -Scope Global -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
function Update-EntraSignedInUserPassword {
function Set-EntraSignedInUserPassword {
[Alias("Update-EntraSignedInUserPassword")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this

[CmdletBinding(DefaultParameterSetName = 'Default')]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies the new password for the signed-in user.")]
Expand Down Expand Up @@ -55,3 +56,4 @@ function Update-EntraSignedInUserPassword {
}
}

Set-Alias -Name Update-EntraSignedInUserPassword -Value Set-EntraSignedInUserPassword -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 @@ -214,7 +214,7 @@
"Set-EntraUserPassword": "Users",
"Set-EntraUserThumbnailPhoto": "Users",
"Update-EntraOauth2PermissionGrant":"SignIns",
"Update-EntraSignedInUserPassword": "Users",
"Set-EntraSignedInUserPassword": "Users",
"Reset-EntraStrongAuthenticationMethodByUpn": "Authentication",
"Get-EntraAttributeSet": "DirectoryManagement",
"New-EntraAttributeSet": "DirectoryManagement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
function Update-EntraBetaSignedInUserPassword {
function Set-EntraBetaSignedInUserPassword {
[CmdletBinding(DefaultParameterSetName = 'Default')]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies the new password for the signed-in user.")]
Expand Down Expand Up @@ -55,3 +55,4 @@ function Update-EntraBetaSignedInUserPassword {
}
}

Set-Alias -Name Update-EntraBetaSignedInUserPassword -Value Set-EntraBetaSignedInUserPassword -Scope Global -Force
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function Enable-EntraAzureADAlias {
Set-Alias -Name Get-AzureADDeviceRegisteredUser -Value Get-EntraBetaDeviceRegisteredUser -Scope Global -Force
Set-Alias -Name Remove-AzureADGroupMember -Value Remove-EntraBetaGroupMember -Scope Global -Force
Set-Alias -Name New-AzureADMSConditionalAccessPolicy -Value New-EntraBetaConditionalAccessPolicy -Scope Global -Force
Set-Alias -Name Update-AzureADSignedInUserPassword -Value Update-EntraBetaSignedInUserPassword -Scope Global -Force
Set-Alias -Name Update-AzureADSignedInUserPassword -Value Set-EntraBetaSignedInUserPassword -Scope Global -Force
Set-Alias -Name Set-AzureADMSAdministrativeUnit -Value Set-EntraBetaAdministrativeUnit -Scope Global -Force
Set-Alias -Name Get-AzureADUserOAuth2PermissionGrant -Value Get-EntraBetaUserOAuth2PermissionGrant -Scope Global -Force
Set-Alias -Name New-AzureADPrivilegedRoleAssignment -Value New-EntraBetaPrivilegedRoleAssignment -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 @@ -25,7 +25,7 @@
"Set-EntraBetaUserManager": "Users",
"Set-EntraBetaUserPassword": "Users",
"Set-EntraBetaUserThumbnailPhoto": "Users",
"Update-EntraBetaSignedInUserPassword": "Users",
"Set-EntraBetaSignedInUserPassword": "Users",
"Get-EntraBetaGroup": "Groups",
"New-EntraBetaGroup": "Groups",
"Set-EntraBetaGroup": "Groups",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: This article provides details on the Update-EntraBetaSignedInUserPassword command.
description: This article provides details on the Set-EntraBetaSignedInUserPassword command.
external help file: Microsoft.Entra.Beta.Users-Help.xml
Locale: en-US
manager: mwongerapk
Expand All @@ -8,12 +8,12 @@ ms.author: eunicewaweru
ms.date: 07/26/2024
ms.reviewer: stevemutungi
ms.topic: reference
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra.Beta/Update-EntraBetaSignedInUserPassword
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra.Beta/Set-EntraBetaSignedInUserPassword
schema: 2.0.0
title: Update-EntraBetaSignedInUserPassword
title: Set-EntraBetaSignedInUserPassword
---

# Update-EntraBetaSignedInUserPassword
# Set-EntraBetaSignedInUserPassword

## SYNOPSIS

Expand All @@ -22,15 +22,15 @@ Updates the password for the signed-in user.
## SYNTAX

```powershell
Update-EntraBetaSignedInUserPassword
Set-EntraBetaSignedInUserPassword
-CurrentPassword <SecureString>
-NewPassword <SecureString>
[<CommonParameters>]
```

## DESCRIPTION

The `Update-EntraBetaSignedInUserPassword` cmdlet updates the password for the signed-in user in Microsoft Entra ID.
The `Set-EntraBetaSignedInUserPassword` cmdlet with alias `Update-EntraBetaSignedInUserPassword` updates the password for the signed-in user in Microsoft Entra ID.

Enable users to update their own passwords. Any user can change their password without requiring administrator privileges.

Expand All @@ -42,7 +42,7 @@ Enable users to update their own passwords. Any user can change their password w
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$currentPassword = ConvertTo-SecureString '<strong-password>' -AsPlainText -Force
$newPassword = ConvertTo-SecureString '<strong-password>' -AsPlainText -Force
Update-EntraBetaSignedInUserPassword -CurrentPassword $currentPassword -NewPassword $newPassword
Set-EntraBetaSignedInUserPassword -CurrentPassword $currentPassword -NewPassword $newPassword
```

This example shows how to update the password for the signed-in user.
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 Update-EntraSignedInUserPassword command.
description: This article provides details on the Set-EntraSignedInUserPassword command.
external help file: Microsoft.Entra.Users-Help.xml
Locale: en-US
manager: mwongerapk
Expand All @@ -9,12 +9,12 @@ ms.author: eunicewaweru
ms.date: 08/20/2024
ms.reviewer: stevemutungi
ms.topic: reference
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra/Update-EntraSignedInUserPassword
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra/Set-EntraSignedInUserPassword
schema: 2.0.0
title: Update-EntraSignedInUserPassword
title: Set-EntraSignedInUserPassword
---

# Update-EntraSignedInUserPassword
# Set-EntraSignedInUserPassword

## SYNOPSIS

Expand All @@ -23,15 +23,15 @@ Updates the password for the signed-in user.
## SYNTAX

```powershell
Update-EntraSignedInUserPassword
Set-EntraSignedInUserPassword
-NewPassword <SecureString>
-CurrentPassword <SecureString>
[<CommonParameters>]
```

## DESCRIPTION

The `Update-EntraSignedInUserPassword` cmdlet updates the password for the signed-in user in Microsoft Entra ID.
The `Set-EntraSignedInUserPassword` cmdlet with the alias `Update-EntraSignedInUserPassword` updates the password for the signed-in user in Microsoft Entra ID.

Enable users to update their own passwords. Any user can change their password without requiring administrator privileges.

Expand All @@ -43,7 +43,7 @@ Enable users to update their own passwords. Any user can change their password w
Connect-Entra -Scopes 'Directory.AccessAsUser.All'
$currentPassword = ConvertTo-SecureString '<strong-password>' -AsPlainText -Force
$newPassword = ConvertTo-SecureString '<strong-password>' -AsPlainText -Force
Update-EntraSignedInUserPassword -CurrentPassword $currentPassword -NewPassword $newPassword
Set-EntraSignedInUserPassword -CurrentPassword $currentPassword -NewPassword $newPassword
```

This example shows how to update the password for the signed-in user.
Expand Down
2 changes: 1 addition & 1 deletion src/AzureADPreviewToEntraBetaMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,5 @@
"Set-AzureADUserManager" : "Set-EntraBetaUserManager",
"Set-AzureADUserPassword" : "Set-EntraBetaUserPassword",
"Set-AzureADUserThumbnailPhoto" : "Set-EntraBetaUserThumbnailPhoto",
"Update-AzureADSignedInUserPassword" : "Update-EntraBetaSignedInUserPassword"
"Update-AzureADSignedInUserPassword" : "Set-EntraBetaSignedInUserPassword"
}
2 changes: 1 addition & 1 deletion src/AzureADToEntraMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,5 @@
"Set-AzureADUserManager" : "Set-EntraUserManager",
"Set-AzureADUserPassword" : "Set-EntraUserPassword",
"Set-AzureADUserThumbnailPhoto" : "Set-EntraUserThumbnailPhoto",
"Update-AzureADSignedInUserPassword" : "Update-EntraSignedInUserPassword"
"Update-AzureADSignedInUserPassword" : "Set-EntraSignedInUserPassword"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,61 @@ BeforeAll {
$CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
}
Describe "Tests for Update-EntraSignedInUserPassword" {
Context "Test for Update-EntraSignedInUserPassword" {
Describe "Tests for Set-EntraSignedInUserPassword" {
Context "Test for Set-EntraSignedInUserPassword" {
It "should return empty object" {
$result = Set-EntraSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword
$result | Should -BeNullOrEmpty
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Entra.Users -Times 1
}
It "Should fail when CurrentPassword is null" {
{ Set-EntraSignedInUserPassword -CurrentPassword } | Should -Throw "Missing an argument for parameter 'CurrentPassword'*"
}
It "Should fail when CurrentPassword is empty" {
{ Set-EntraSignedInUserPassword -CurrentPassword "" } | Should -Throw "Cannot process argument transformation on parameter 'CurrentPassword'*"
}
It "Should fail when NewPassword is null" {
{ Set-EntraSignedInUserPassword -NewPassword } | Should -Throw "Missing an argument for parameter 'NewPassword'*"
}
It "Should fail when NewPassword is empty" {
{ Set-EntraSignedInUserPassword -NewPassword "" } | Should -Throw "Cannot process argument transformation on parameter 'NewPassword'*"
}

It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraSignedInUserPassword"

Set-EntraSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword

$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraSignedInUserPassword"

Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Entra.Users -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}

It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{
Set-EntraSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword -Debug
} | Should -Not -Throw
}
finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}

}
}

Describe "Tests for the alias Update-EntraSignedInUserPassword" {
Context "Test for the alias Update-EntraSignedInUserPassword" {
It "should return empty object" {
$result = Update-EntraSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword
$result | Should -BeNullOrEmpty
Expand All @@ -38,11 +91,11 @@ Describe "Tests for Update-EntraSignedInUserPassword" {
}

It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Update-EntraSignedInUserPassword"
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraSignedInUserPassword"

Update-EntraSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword

$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Update-EntraSignedInUserPassword"
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraSignedInUserPassword"

Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Entra.Users -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,73 @@ BeforeAll {
Mock -CommandName Get-EntraContext -MockWith { @{Scopes = @("Directory.AccessAsUser.All") } } -ModuleName Microsoft.Entra.Beta.Users
}

Describe "Tests for Update-EntraBetaSignedInUserPassword" {
Describe "Tests for Set-EntraBetaSignedInUserPassword" {
Context "Test for Set-EntraBetaSignedInUserPassword" {
It "should updates the password for the signed-in user." {
$CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
$result = Set-EntraBetaSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword
$result | Should -BeNullOrEmpty
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Entra.Beta.Users -Times 1
}

It "Should fail when CurrentPassword is null" {
{ $CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
Set-EntraBetaSignedInUserPassword -CurrentPassword -NewPassword $NewPassword } | Should -Throw "Missing an argument for parameter 'CurrentPassword'*"
}

It "Should fail when CurrentPassword is empty" {
{ $CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
Set-EntraBetaSignedInUserPassword -CurrentPassword "" -NewPassword $NewPassword } | Should -Throw "Cannot process argument transformation on parameter 'CurrentPassword'*"
}

It "Should fail when NewPassword is null" {
{ $CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
Set-EntraBetaSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword } | Should -Throw "Missing an argument for parameter 'NewPassword'*"
}

It "Should fail when NewPassword is empty" {
{ $CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
Set-EntraBetaSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword "" } | Should -Throw "Cannot process argument transformation on parameter 'NewPassword'*"
}

It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaSignedInUserPassword"
$CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
$result = Set-EntraBetaSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword
$result | Should -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaSignedInUserPassword"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Entra.Beta.Users -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}

It "Should execute successfully without throwing an error " {
$CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Set-EntraBetaSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword -Debug } | Should -Not -Throw
}
finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}

Describe "Tests for the Alias Update-EntraBetaSignedInUserPassword" {
Context "Test for Update-EntraBetaSignedInUserPassword" {
It "should updates the password for the signed-in user." {
$CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
Expand Down Expand Up @@ -50,12 +116,12 @@ Describe "Tests for Update-EntraBetaSignedInUserPassword" {
}

It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Update-EntraBetaSignedInUserPassword"
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaSignedInUserPassword"
$CurrentPassword = ConvertTo-SecureString 'test@123' -AsPlainText -Force
$NewPassword = ConvertTo-SecureString 'test@1234' -AsPlainText -Force
$result = Update-EntraBetaSignedInUserPassword -CurrentPassword $CurrentPassword -NewPassword $NewPassword
$result | Should -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Update-EntraBetaSignedInUserPassword"
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaSignedInUserPassword"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Entra.Beta.Users -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
Expand Down