Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -2,7 +2,7 @@
"tool": "Credential Scanner",
"suppressions": [
{
"file": "test_legacy\\module\\Entra\\Update-EntraSignedInUserPassword.Tests.ps1",
"file": "test_legacy\\module\\Entra\\Set-EntraSignedInUserPassword.Tests.ps1",
"_justification": "Unit test file has a sample Password used in mocking."
},
{
Expand All @@ -18,7 +18,7 @@
"_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."
},
{
Expand Down
8 changes: 4 additions & 4 deletions .config/guardian/.gdnbaselines
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"alternativeSignatures": [
"a1562a9034f1e3e1b3f4469395192d20944cec736650f1c5e9d2770a14734188"
],
"target": "test/module/Entra/Update-EntraSignedInUserPassword.Tests.ps1",
"target": "test/module/Entra/Set-EntraSignedInUserPassword.Tests.ps1",
"line": 13,
"memberOf": [
"default"
Expand All @@ -112,7 +112,7 @@
"alternativeSignatures": [
"9235224cea5d1fd6c3804bf4140c4cdc6d847a2e665e3539236f553f4d49b381"
],
"target": "test/module/Entra/Update-EntraSignedInUserPassword.Tests.ps1",
"target": "test/module/Entra/Set-EntraSignedInUserPassword.Tests.ps1",
"line": 14,
"memberOf": [
"default"
Expand Down Expand Up @@ -218,7 +218,7 @@
"58713463161cdc938252fba801ccde6c337f09d4407a41d6902e6bc4d9f6bde2": {
"signature": "58713463161cdc938252fba801ccde6c337f09d4407a41d6902e6bc4d9f6bde2",
"alternativeSignatures": [],
"target": "test/module/Entra/Update-EntraSignedInUserPassword.Tests.ps1",
"target": "test/module/Entra/Set-EntraSignedInUserPassword.Tests.ps1",
"line": 13,
"memberOf": [
"default"
Expand All @@ -232,7 +232,7 @@
"d6495c0e685f44d528d82c01d7657b3f0e3710810105115db140afb8b6ddbc2e": {
"signature": "d6495c0e685f44d528d82c01d7657b3f0e3710810105115db140afb8b6ddbc2e",
"alternativeSignatures": [],
"target": "test/module/Entra/Update-EntraSignedInUserPassword.Tests.ps1",
"target": "test/module/Entra/Set-EntraSignedInUserPassword.Tests.ps1",
"line": 14,
"memberOf": [
"default"
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
@@ -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 @@ -11,10 +11,10 @@ ms.reviewer: stevemutungi
ms.topic: reference
online version: https://learn.microsoft.com/powershell/module/Microsoft.Entra/Update-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/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 @@ -16,8 +16,60 @@ 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.Graph.Entra -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.Graph.Entra -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 Down Expand Up @@ -66,4 +118,4 @@ Describe "Tests for Update-EntraSignedInUserPassword"{
}

}
}
}