Skip to content

Commit

Permalink
UserLocal: Fix change password with PS 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alagoutte committed Sep 10, 2024
1 parent b80db1b commit f33c5f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion PowerFGT/Public/cmdb/user/local.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ function Set-FGTUserLocal {
if ($connection.version -ge "7.4.0") {
Throw "Can't change passwd with FortiOS > 7.4.0 (Need to use Set-FGTMonitorUserLocalChangePassword)"
}
$password = ConvertFrom-SecureString -SecureString $passwd -AsPlainText
if (("Desktop" -eq $PSVersionTable.PsEdition) -or ($null -eq $PSVersionTable.PsEdition)) {
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($passwd);
$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr);
}
else {
$password = ConvertFrom-SecureString -SecureString $passwd -AsPlainText
}
}

if ( $PSCmdlet.ParameterSetName -ne "default" -and $userlocal.type -ne $PSCmdlet.ParameterSetName ) {
Expand Down

0 comments on commit f33c5f7

Please sign in to comment.