Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Get-AzKeyVaultSecret's example for constrained language mode #13496

Closed
isra-fel opened this issue Nov 13, 2020 · 0 comments · Fixed by #13620
Closed

Update Get-AzKeyVaultSecret's example for constrained language mode #13496

isra-fel opened this issue Nov 13, 2020 · 0 comments · Fixed by #13620

Comments

@isra-fel
Copy link
Member

isra-fel commented Nov 13, 2020

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().Password

What to do

  • Give the work-around more tests
  • Update help doc
    • Add this work-around
    • BTW also mention ConvertFrom-SecureString -AsPlainText in PowerShell 7

Cost

1

@isra-fel isra-fel added KeyVault Engineering Doc - Reference needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Nov 13, 2020
@isra-fel isra-fel added this to the S179 (2020-12-08) milestone Nov 13, 2020
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Nov 13, 2020
@isra-fel isra-fel self-assigned this Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant