# Shorten this dns txt record request script as much as possible

I have made a short script that will pull dns txt records down from a server and combine them into a single string. DNS txt records are:

1.website.com 2.website.com 3.website.com

Each of these are iterated through using the single digit number.
The double quotes at the beginning and the end of the strings are trimmed
This works exactly as I would like it too I am simply interested in seeing how short I can get it

$i = 1 1..2 | foreach {$w="$i.website.com" sv -N v -Va ((nslookup -q=txt$w )[-1]).Trim().Trim('"')
$p += "$v"
$i += 1 }  and ideally I'd like to return the $p variable, that being the concatenated string

this is what I ended getting it down to

1..2|%{$p+=Resolve-DnsName "$_.website.com." -Ty TXT -EA 0|% S*s};powershell .(\$p)

• What's the scoring criterion? Sep 16 at 10:17
• What approaches have you already tried to shorten the code? From meta: 'Simply dumping code and saying "How can this be shorter?" is not acceptable. The poster needs to state things they've tried or point out specific parts they think could be improved.' Sep 16 at 14:39
• edited with what I got to work eventually Sep 17 at 3:44