Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/KeyVault/KeyVault/help/Get-AzKeyVaultCertificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,24 @@ Updated : 2/8/2016 11:21:45 PM
```

### Example 2: Get cert and save it as pfx
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.

```powershell
$cert = Get-AzKeyVaultCertificate -VaultName $vaultName -Name $certName
$secret = Get-AzKeyVaultSecret -VaultName $vaultName -Name $cert.Name
$secretByte = [Convert]::FromBase64String(($secret.SecretValue | ConvertFrom-SecureString -AsPlainText))
$secret = Get-AzKeyVaultSecret -VaultName $vaultName -Name $cert.Name -AsPlainText
# Write to a file
[System.IO.File]::WriteAllBytes("cert.pfx", $secretByte)
Set-Content -Path cert.pfx -Value $secret -PassThru
```

```output
-----BEGIN PRIVATE KEY-----
******************************
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
******************************
-----END CERTIFICATE-----
```

This command gets the certificate named `$certName` from the key vault named `$vaultName`. These commands access secret `$cert.Name` and then save the content as a pfx file.

### Example 3: Get all the certificates that have been deleted but not purged for this key vault.
```powershell
Get-AzKeyVaultCertificate -VaultName 'contoso' -InRemovedState
Expand Down