-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Description
Description
The way our current example converts secure string secret to plain text secret does not work in PowerShell constrained language mode, because
Only allowed types (listed below) can be used in PowerShell. Other types are not permitted.
(See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-7.1#constrained-language-constrained-language)
and System.Runtime.InteropServices.Marshal is not in the the list.
@TylerLeonhardt suggested a work-around by using PSCredential class (thanks Tyler!)
$securestr = (Get-AzKeyVaultSecret -Name Foo -VaultName bar).SecretText
[pscredential]::new("DoesntMatter", $securestr).GetNetworkCredential().PasswordWhat to do
- Give the work-around more tests
- Update help doc
- Add this work-around
- BTW also mention
ConvertFrom-SecureString -AsPlainTextin PowerShell 7
Cost
1
TylerLeonhardt