How to set multiline TXT fields with Add-DnsServerResourceRecord?

I want to use DNS Policies (ZoneScope), and this requires that I use Powershell Cmdlets to manage DNS entries, as it can't be done via the DNS MMC.
Below is an example of a multiline TXT record I want to create ... I can just paste this in when using the DNS MMC to create a multiline TXT record dnsmg.png (but that is the default and cannot be targeted to a specific ZoneScope). DNSCMD.EXE does support multiline TXT records, but it does not support ZoneScopes.
When I try to add the record (here without ZoneScope for simplicity) Add-DnsServerResourceRecord -DescriptiveText "$txtrecords" -Name test4._tcp._ipps -Txt -ZoneName $domain -TimeToLive 0:1:0:0
I get an error (adsrr.png), which appears to be because the $txtrecords data is too big (when I shorten $txtrecords, it works).
How can I create a multi-line TXT record, in a ZoneScope, using Add-DnsServerResourceRecord?
txtvers=1
qtotal=1
rp=ipp/print/printer7
product=printer7
URF=CP255,DM1,FN3-4-5-8-20,IS1-4,OB10,PQ4,RS300,SRGB24,V1.4,W8
pdl=image/urf,application/octet-stream,image/jpeg,application/pdf
adminurl=https://myhost.mydomain.com/ipp/something:8008/printer.htm?name=printer7
kind=document,envelope,postcode
air=username,password
note=Test printer
Binary=T
Bind=F
Color=T
Collate=T
Copies=T
Duplex=T
Fax=F
Scan=F
Staple=T
Transparent=T
Punch=2
PaperMax=tabloid-A3
TLS=1.2
Thanks Rich; sadly the all the data needs to be in one TXT record.
It's very weird how these restrictions exist;
I don't see a solution ... ? Pity the DescriptiveText parameter is a string, and not a string array...
The reason the GUI works is because the code for that works directly with the DNS API.
The conundrum you're experiencing originates with the DNS group. PowerShell provides a means for the various groups to provide easy ways to script (rather than compile) common activities. The problems arise when the code behind the cmdlets no longer matches the features offered by the product.
One way around this is to give up the AD integration and use zone files (just like we still do when using BIND). Then you'd be working with text files and it's very easy to find examples of how to automate the management of additions/deletions/changes/synchronization. Yeah, you have to set up the primary/secondary zone updates but, in reality, the event-driven synchronization works just as well -- it just requires a bit more planning.
Thanks for the suggestion. I used to run a BIND server ... but don't really want to go there as it means more involvement/change than I want to deal with at the moment.
I've worked out another way to do it ... in the TXT record is a URL ("myhost.mydomain.com") ... so instead of making the TXT record vary under policy, I will use a CNAME for "myhost" and use DNS policies to make that resolve to different servers. I'm lucky that the TXT record is standard across what I need, and that doing it this way will work for me! It would be really great to be able to manage longer TXT records with PS/WMI though!
You aren't the first to complain about this particular problem. I doubt you'll be the last. :-(
Sign in to comment