Skip to content

Commit

Permalink
Fix Powershell 5 -AsPLainText on ConvertFrom-SecureString
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Moreau committed Sep 3, 2024
1 parent 601ce0f commit 1c745fc
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 @@ -79,7 +79,13 @@ function Add-FGTUserLocal {
}

if ($PsBoundParameters.ContainsKey('passwd')) {
$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 ( Get-FGTUserLocal @invokeParams -name $name -connection $connection) {
Expand Down

0 comments on commit 1c745fc

Please sign in to comment.