public override void ExecuteCmdlet() { bool deleted = false; DnsRecordSet recordSetToDelete = null; if (this.ParameterSetName == "Fields") { if (this.Name.EndsWith(".")) { this.Name = this.Name.TrimEnd('.'); this.WriteWarning(string.Format("Modifying recordset name to remove terminating '.'. Recordset name used is \"{0}\".", this.Name)); } recordSetToDelete = new DnsRecordSet { Name = this.Name, Etag = null, RecordType = this.RecordType, ResourceGroupName = this.ResourceGroupName, ZoneName = this.ZoneName, }; } else if (this.ParameterSetName == "Mixed") { if (this.Name.EndsWith(".")) { this.Name = this.Name.TrimEnd('.'); this.WriteWarning(string.Format("Modifying recordset name to remove terminating '.'. Recordset name used is \"{0}\".", this.Name)); } recordSetToDelete = new DnsRecordSet { Name = this.Name, Etag = null, RecordType = this.RecordType, ResourceGroupName = this.Zone.ResourceGroupName, ZoneName = this.Zone.Name, }; } else if (this.ParameterSetName == "Object") { if ((string.IsNullOrWhiteSpace(this.RecordSet.Etag) || this.RecordSet.Etag == "*") && !this.Overwrite.IsPresent) { throw new PSArgumentException(string.Format(ProjectResources.Error_EtagNotSpecified, typeof(DnsRecordSet).Name)); } recordSetToDelete = this.RecordSet; } if (recordSetToDelete.ZoneName != null && recordSetToDelete.ZoneName.EndsWith(".")) { recordSetToDelete.ZoneName = recordSetToDelete.ZoneName.TrimEnd('.'); this.WriteWarning(string.Format("Modifying zone name to remove terminating '.'. Zone name used is \"{0}\".", recordSetToDelete.ZoneName)); } bool overwrite = this.Overwrite.IsPresent || this.ParameterSetName != "Object"; ConfirmAction( ProjectResources.Progress_RemovingRecordSet, this.Name, () => { deleted = DnsClient.DeleteDnsRecordSet(recordSetToDelete, overwrite); if (deleted) { WriteVerbose(ProjectResources.Success); WriteVerbose(ProjectResources.Success_RemoveRecordSet); } if (this.PassThru) { WriteObject(deleted); } }); }