Skip to content

Commit 2c0c5e4

Browse files
authored
correct the way to download keyvault certificate (#15163)
1 parent 64f1f90 commit 2c0c5e4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,11 @@ Updated : 2/8/2016 11:21:45 PM
107107
This command gets the certificate named TestCert01 from the key vault named ContosoKV01. To download the certificate as pfx file, run following command. These commands access SecretId and then save the content as a pfx file.
108108

109109
```powershell
110-
$cert = Get-AzKeyVaultCertificate -VaultName "ContosoKV01" -Name "TestCert01"
110+
$cert = Get-AzKeyVaultCertificate -VaultName $vaultName -Name $certName
111111
$secret = Get-AzKeyVaultSecret -VaultName $vaultName -Name $cert.Name -AsPlainText
112112
$secretByte = [Convert]::FromBase64String($secret)
113-
$x509Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($secretByte, "", "Exportable,PersistKeySet")
114-
$type = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx
115-
$pfxFileByte = $x509Cert.Export($type, $password)
116-
117113
# Write to a file
118-
[System.IO.File]::WriteAllBytes("KeyVault.pfx", $pfxFileByte)
114+
[System.IO.File]::WriteAllBytes("cert.pfx", $secretByte)
119115
```
120116

121117
### Example 3: Get all the certificates that have been deleted but not purged for this key vault.

0 commit comments

Comments
 (0)