/// <summary> /// Method to execute the command /// </summary> private void GetVaultSettingsFile() { IAzureSubscription subscription = DefaultProfile.DefaultContext.Subscription; // Generate certificate X509Certificate2 cert = CertUtils.CreateSelfSignedCertificate(VaultCertificateExpiryInHoursForHRM, subscription.Id.ToString(), this.Vault.Name); ASRSite site = new ASRSite(); if (!string.IsNullOrEmpty(this.SiteIdentifier) && !string.IsNullOrEmpty(this.SiteFriendlyName)) { site.ID = this.SiteIdentifier; site.Name = this.SiteFriendlyName; } // Generate file. ASRVaultCreds vaultCreds = RecoveryServicesClient.GenerateVaultCredential( cert, this.Vault, site); string filePath = string.IsNullOrEmpty(this.Path) ? Utilities.GetDefaultPath() : this.Path; string fileName = this.GenerateFileName(); // write the content to a file. VaultSettingsFilePath output = new VaultSettingsFilePath() { FilePath = Utilities.WriteToFile <ASRVaultCreds>(vaultCreds, filePath, fileName) }; // print the path to the user. this.WriteObject(output, true); }