public override void ExecuteCmdlet() { if (ShouldProcess(Name, Properties.Resources.SetCertificatePolicy)) { PSKeyVaultCertificatePolicy policy = new PSKeyVaultCertificatePolicy(); switch (ParameterSetName) { case ExpandedRenewNumberParameterSet: case ExpandedRenewPercentageParameterSet: policy = new PSKeyVaultCertificatePolicy( DnsName, (KeyUsage == null || !KeyUsage.Any()) ? null : KeyUsage.Select(keyUsage => keyUsage.ToString()).ToList <string>(), Ekus, !Disabled.IsPresent, IssuerName, CertificateType, RenewAtNumberOfDaysBeforeExpiry, RenewAtPercentageLifetime, EmailAtNumberOfDaysBeforeExpiry, EmailAtPercentageLifetime, ReuseKeyOnRenewal, SecretContentType, SubjectName, ValidityInMonths, KeyType, KeySize, Curve, KeyNotExportable.IsPresent ? !KeyNotExportable.IsPresent : (bool?)null, CertificateTransparency ?? (bool?)null); break; case ByValueParameterSet: InputObject.Validate(); policy = InputObject; break; } var resultantPolicy = DataServiceClient.UpdateCertificatePolicy(VaultName, Name, policy.ToCertificatePolicy()); if (PassThru.IsPresent) { this.WriteObject(resultantPolicy); } } }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, Properties.Resources.SetCertificatePolicy)) { PSKeyVaultCertificatePolicy policy = new PSKeyVaultCertificatePolicy(); switch (ParameterSetName) { case ExpandedRenewNumberParameterSet: case ExpandedRenewPercentageParameterSet: // Validate input parameters ValidateSubjectName(); ValidateDnsNames(); ValidateKeyUsage(); ValidateEkus(); policy = new PSKeyVaultCertificatePolicy { DnsNames = DnsName, KeyUsage = KeyUsage, Ekus = Ekus, Enabled = !Disabled.IsPresent, IssuerName = IssuerName, CertificateType = CertificateType, RenewAtNumberOfDaysBeforeExpiry = RenewAtNumberOfDaysBeforeExpiry, RenewAtPercentageLifetime = RenewAtPercentageLifetime, EmailAtNumberOfDaysBeforeExpiry = EmailAtNumberOfDaysBeforeExpiry, EmailAtPercentageLifetime = EmailAtPercentageLifetime, SecretContentType = SecretContentType, SubjectName = SubjectName, ValidityInMonths = ValidityInMonths, Kty = KeyType, Exportable = KeyNotExportable.IsPresent ? !KeyNotExportable.IsPresent : (bool?)null }; if (ReuseKeyOnRenewal.HasValue) { policy.ReuseKeyOnRenewal = ReuseKeyOnRenewal.Value; } break; case ByValueParameterSet: policy = InputObject; break; } var resultantPolicy = DataServiceClient.UpdateCertificatePolicy(VaultName, Name, policy.ToCertificatePolicy()); if (PassThru.IsPresent) { this.WriteObject(PSKeyVaultCertificatePolicy.FromCertificatePolicy(resultantPolicy)); } } }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, Properties.Resources.SetCertificatePolicy)) { PSKeyVaultCertificatePolicy policy = new PSKeyVaultCertificatePolicy(); switch (ParameterSetName) { case ExpandedRenewNumberParameterSet: case ExpandedRenewPercentageParameterSet: // Validate input parameters ValidateSubjectName(); ValidateDnsNames(); ValidateEkus(); List <string> convertedKeyUsage = null; if (KeyUsage != null) { convertedKeyUsage = new List <string>(); foreach (var key in KeyUsage) { convertedKeyUsage.Add(key.ToString()); } } policy = new PSKeyVaultCertificatePolicy { DnsNames = DnsName, KeyUsage = convertedKeyUsage, Ekus = Ekus, Enabled = !Disabled.IsPresent, IssuerName = IssuerName, CertificateType = CertificateType, RenewAtNumberOfDaysBeforeExpiry = RenewAtNumberOfDaysBeforeExpiry, RenewAtPercentageLifetime = RenewAtPercentageLifetime, EmailAtNumberOfDaysBeforeExpiry = EmailAtNumberOfDaysBeforeExpiry, EmailAtPercentageLifetime = EmailAtPercentageLifetime, SecretContentType = SecretContentType, SubjectName = SubjectName, ValidityInMonths = ValidityInMonths, Kty = KeyType, Exportable = KeyNotExportable.IsPresent ? !KeyNotExportable.IsPresent : (bool?)null, CertificateTransparency = CertificateTransparency ?? (bool?)null }; if (MyInvocation.BoundParameters.ContainsKey("ReuseKeyOnRenewal")) { policy.ReuseKeyOnRenewal = ReuseKeyOnRenewal; } break; case ByValueParameterSet: policy = InputObject; break; } var resultantPolicy = DataServiceClient.UpdateCertificatePolicy(VaultName, Name, policy.ToCertificatePolicy()); if (PassThru.IsPresent) { this.WriteObject(resultantPolicy); } } }