question

PeizhiYu avatar image
0 Votes"
PeizhiYu asked GaryReynolds answered

Add txt record to dns server

I want to add a txt record to dns server, but the record more than 255 char.


This is my cmdlet:

PS C:\Users\Administrator> $txt = "v=DKIM1;k=rsa;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy6OAXCmjYT823gq+DXRjXdsypt7iepfl4pkvLRVN8wRwoND2Fk2aVlG+CitAeJ0nqWn7JAPjoTXpFtHnOWMN7ay/atQd+DcLLHfJkpRvsYSDQ1jkI2s7CkWF6G+nwLGJcNFndOdB8oawpppyESE7+DiZae8bDicaTK8oPU0J7iogeZ1fgvmutwNtNzZHiSgwF9euCiX6lTmGe+0oZ+gRUJnUmZevh//IZ+NyDkRV2kPxQBtM8brHUpRL1c11q/CA0kC6C3ku+Pqmf6A8CGT+qvlCeQ2lVqlBydQL5UjiixUEwkSrgUEKoKE2Hqw97WrDEJZqngtuqma9hWoAsKVbzwIDAQAB"

PS C:\Users\Administrator> $txt_part1 = $txt.Substring(0,252)
PS C:\Users\Administrator> $txt_part2 = $txt.Substring(252,$txt.Length - 252)
PS C:\Users\Administrator> Add-DnsServerResourceRecord -DescriptiveText "$txt_part1","$txt_part2" -Name test -Txt -ZoneName test.local
Add-DnsServerResourceRecord : Cannot process argument transformation on parameter 'DescriptiveText'. Cannot convert
value to type System.String.
At line:1 char:46
+ ... rverResourceRecord -DescriptiveText "$txt_part1","$txt_part2" -Name t ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-DnsServerResourceRecord], ParameterBindingArgumentTransformationEx
ception
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DnsServerResourceRecord



What should I do?



windows-dhcp-dns
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GaryReynolds avatar image
0 Votes"
GaryReynolds answered

Hi @PeizhiYu

You have a format error in the add record command, have a look at example 8 on the command page. https://docs.microsoft.com/en-us/powershell/module/dnsserver/add-dnsserverresourcerecord?view=windowsserver2022-ps#example-8--add-a-multiline-txt-resource-record

 Add-DnsServerResourceRecord -DescriptiveText "$txt_part1`r`n$txt_part2" -Name text -Txt -ZoneName test.local

Gary.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.