Skip to content

Commit 497e1fa

Browse files
author
Muralidhar Ranganathan
authored
Mitigate Get-AzKeyVaultSecret: Invalid Parameter AsPlainText (Azure#16730)
When I copied the code and executed it, I received the below error, Get-AzKeyVaultSecret: A parameter cannot be found that matches parameter name 'AsPlainText'. I have tested this fix with one of my Key Vaults. I was able to verify the file generated as result is valid and usable.
1 parent 51e00c1 commit 497e1fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/KeyVault/KeyVault/help/Get-AzKeyVaultCertificate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ This command gets the certificate named TestCert01 from the key vault named Cont
108108

109109
```powershell
110110
$cert = Get-AzKeyVaultCertificate -VaultName $vaultName -Name $certName
111-
$secret = Get-AzKeyVaultSecret -VaultName $vaultName -Name $cert.Name -AsPlainText
112-
$secretByte = [Convert]::FromBase64String($secret)
111+
$secret = Get-AzKeyVaultSecret -VaultName $vaultName -Name $cert.Name
112+
$secretByte = [Convert]::FromBase64String(($secret.SecretValue | ConvertFrom-SecureString -AsPlainText))
113113
# Write to a file
114114
[System.IO.File]::WriteAllBytes("cert.pfx", $secretByte)
115115
```

0 commit comments

Comments
 (0)