Skip to content

Commit be081e0

Browse files
authored
Merge pull request #104849 from pvrk/Jan2020Local
Fixing certificate error with PS
2 parents dec598e + 33d7551 commit be081e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

articles/backup/backup-client-automation.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,16 @@ $CredsFilename = Get-AzRecoveryServicesVaultSettingsFile -Backup -Vault $Vault1
129129

130130
### Registering using the PS Az module
131131

132+
> [!NOTE]
133+
> A bug with generation of vault certificate is fixed in Az 3.5.0 release. Use Az 3.5.0 release version or greater to download a vault certificate.
134+
132135
In the latest Az module of Powershell, due to underlying platform limitations, downloading the vault credentials requires a self-signed certificate. The following example shows how to provide a self-signed certificate and download the vault credentials.
133136

134137
```powershell
135-
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $rgName -Name $VaultName
136-
$cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname xxxxxxxxxxxxx
137-
$certificate =[System.Convert]::ToBase64String($cert.RawData)
138-
$CredsPath = "C:\downloads"
139-
$CredsFilename = Get-AzRecoveryServicesVaultSettingsFile -Certificate $certificate -Vault $vault -Backup -Path $CredsPath
138+
$dt = $(Get-Date).ToString("M-d-yyyy")
139+
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -FriendlyName 'test-vaultcredentials' -subject "Windows Azure Tools" -KeyExportPolicy Exportable -NotAfter $(Get-Date).AddHours(48) -NotBefore $(Get-Date).AddHours(-24) -KeyProtection None -KeyUsage None -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") -Provider "Microsoft Enhanced Cryptographic Provider v1.0"
140+
$certficate = [convert]::ToBase64String($cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx))
141+
$CredsFilename = Get-AzRecoveryServicesVaultSettingsFile -Backup -Vault $Vault -Path $CredsPath -Certificate $certficate
140142
```
141143

142144
On the Windows Server or Windows client machine, run the [Start-OBRegistration](https://technet.microsoft.com/library/hh770398%28v=wps.630%29.aspx) cmdlet to register the machine with the vault.

0 commit comments

Comments
 (0)