diff --git a/PowerFGT/Public/cmdb/user/local.ps1 b/PowerFGT/Public/cmdb/user/local.ps1 index c262dbf4c..758fd8c47 100644 --- a/PowerFGT/Public/cmdb/user/local.ps1 +++ b/PowerFGT/Public/cmdb/user/local.ps1 @@ -383,11 +383,13 @@ function Set-FGTUserLocal { throw "User type ($($userlocal.type)) need to be on the same type ($($PSCmdlet.ParameterSetName))" } - if ($status) { - $_local | add-member -name "status" -membertype NoteProperty -Value "enable" - } - else { - $_local | add-member -name "status" -membertype NoteProperty -Value "disable" + if ($PsBoundParameters.ContainsKey('status')) { + if ($status) { + $_local | add-member -name "status" -membertype NoteProperty -Value "enable" + } + else { + $_local | add-member -name "status" -membertype NoteProperty -Value "disable" + } } switch ( $PSCmdlet.ParameterSetName ) { diff --git a/Tests/integration/UserLocal.Tests.ps1 b/Tests/integration/UserLocal.Tests.ps1 index ff46a10d5..ca6333e7f 100644 --- a/Tests/integration/UserLocal.Tests.ps1 +++ b/Tests/integration/UserLocal.Tests.ps1 @@ -161,7 +161,7 @@ Describe "Configure User Local" { Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -email_to "powerfgt@power.fgt" $userlocal = Get-FGTUserLocal -name $pester_userlocal $userlocal.name | Should -Be $pester_userlocal - $userlocal.status | Should -Be "disable" + $userlocal.status | Should -Be "enable" $userlocal.'email-to' | Should -Be "powerfgt@power.fgt" $userlocal.'two-factor' | Should -Be "disable" } @@ -170,7 +170,7 @@ Describe "Configure User Local" { Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -two_factor email $userlocal = Get-FGTUserLocal -name $pester_userlocal $userlocal.name | Should -Be $pester_userlocal - $userlocal.status | Should -Be "disable" + $userlocal.status | Should -Be "enable" $userlocal.'email-to' | Should -Be "powerfgt@power.fgt" $userlocal.'two-factor' | Should -Be "email" } @@ -179,7 +179,7 @@ Describe "Configure User Local" { Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -passwd $mywrongpassword $userlocal = Get-FGTUserLocal -name $pester_userlocal $userlocal.name | Should -Be $pester_userlocal - $userlocal.status | Should -Be "disable" + $userlocal.status | Should -Be "enable" $userlocal.'email-to' | Should -Be "powerfgt@power.fgt" $userlocal.'two-factor' | Should -Be "email" } @@ -202,7 +202,7 @@ Describe "Configure User Local" { Get-FGTUserLocal -name $pester_userlocal | Set-FGTUserLocal -name "pester_userlocal_change" $userlocal = Get-FGTUserLocal -name "pester_userlocal_change" $userlocal.name | Should -Be "pester_userlocal_change" - $userlocal.status | Should -Be "disable" + $userlocal.status | Should -Be "enable" $userlocal.'email-to' | Should -Be "powerfgt@power.fgt" $userlocal.'two-factor' | Should -Be "email" } @@ -212,7 +212,7 @@ Describe "Configure User Local" { Get-FGTUserLocal -name "pester_userlocal_change" | Set-FGTUserLocal -data $data $userlocal = Get-FGTUserLocal -name "pester_userlocal_change" $userlocal.name | Should -Be "pester_userlocal_change" - $userlocal.status | Should -Be "disable" + $userlocal.status | Should -Be "enable" $userlocal.'email-to' | Should -Be "powerfgt@power.fgt" $userlocal.'two-factor' | Should -Be "email" }