How to resolve Add-DnsServerResourceRecord descriptivetxt 255 character limitation?

Hi all,

I’m trying to create DKIM TXT record through powershell using this command:

Add-DnsServerResourceRecord -Txt -ZoneName <some_zone> -Name <some_name> -DescriptiveText $txt

if the $txt string contains more than 255 character it gives an error like this:

Add-DnsServerResourceRecord : InputObject for resource record has an invalid value.

After many hours of digging I came across this alternative, which involves command outside powershell, and it’s deprecated, along with some other problems:

$cmd = 'dnscmd /recordAdd ’ + $domain_name + ’ ’ + $hostname + ’ txt ’ + $SplittedTxt
Invoke-Expression $cmd

$SplittedTxt string here contains multiple texts in quotes like “one” “who” “three”.

My question is, can I do the same with Add-DnsServerResourceRecord command? because no matter what I put there it gives error. How can I use this command to create TXT record with multiple strings in it to avoid single string length limitation?

Thanks

Is there more than 255 characters in the text you are sending? That is a typical limitation on the database side for that number of characters. Not sure how breaking it up into multiple texts would subvert the 255 character limitation. Add-DnsServerResourceRecord documentation shows that is a STRING value not a STRING (e.g. string array).

-DescriptiveText
Specifies additional text to describe a resource record on a DNS server.

TABLE 20
**Type:	String**
Position:	Named
Default value:	None
Accept pipeline input:	True
Accept wildcard characters:	False

You did not share what is contained in $txt.

$txt contains standard DKIM value like “v=DKIM1; p=MIGf”… but it doesn’t matter what kind of text you put there.

There’s definitely more that 255 characters, yes. But how come I can do more with dnscmd? There must be some way to achieve it with powershell imo.