public override void ExecuteCmdlet() { CertificateBundle certBundle; if (InputObject != null) { VaultName = InputObject.VaultName.ToString(); } if (!string.IsNullOrEmpty(Version)) { certBundle = this.DataServiceClient.GetCertificate(VaultName, Name, Version); var certificate = PSKeyVaultCertificate.FromCertificateBundle(certBundle); this.WriteObject(certificate); } else if (IncludeVersions) { certBundle = this.DataServiceClient.GetCertificate(VaultName, Name, string.Empty); if (certBundle != null) { WriteObject(new PSKeyVaultCertificateIdentityItem(certBundle)); GetAndWriteCertificatesVersions(VaultName, Name, certBundle.CertificateIdentifier.Version); } } else if (InRemovedState) { if (Name == null) { GetAndWriteDeletedCertificates(VaultName); } else { PSDeletedKeyVaultCertificate deletedCert = PSDeletedKeyVaultCertificate.FromDeletedCertificateBundle(DataServiceClient.GetDeletedCertificate(VaultName, Name)); WriteObject(deletedCert); } } else if (!string.IsNullOrEmpty(Name)) { certBundle = this.DataServiceClient.GetCertificate(VaultName, Name, string.Empty); var certificate = PSKeyVaultCertificate.FromCertificateBundle(certBundle); this.WriteObject(certificate); } else { GetAndWriteCertificates(VaultName); } }
public override void ExecuteCmdlet() { if (InputObject != null) { VaultName = InputObject.VaultName; Name = InputObject.Name; } if (InRemovedState.IsPresent) { ConfirmAction( Force.IsPresent, string.Format( CultureInfo.InvariantCulture, Resources.RemoveDeletedCertificateWarning, Name), string.Format( CultureInfo.InvariantCulture, Resources.RemoveDeletedCertificateWhatIfMessage, Name), Name, () => { DataServiceClient.PurgeCertificate(VaultName, Name); }); return; } PSDeletedKeyVaultCertificate certBundle = null; ConfirmAction( Force.IsPresent, string.Format( CultureInfo.InvariantCulture, Resources.RemoveCertWarning, Name), string.Format( CultureInfo.InvariantCulture, Resources.RemoveCertWhatIfMessage, Name), Name, () => { certBundle = PSDeletedKeyVaultCertificate.FromDeletedCertificateBundle(this.DataServiceClient.DeleteCertificate(VaultName, Name)); }); if (PassThru.IsPresent) { WriteObject(certBundle); } }