I have list of the servers, for them I'm used commands Resolve -DnsName
, this command has different parameters and to receive all the data that I need (NS, MX, CNAME, A) records, I need to make multiple commands.
$servers = get-content "C:\Users\Olehsa\Desktop\ttt.txt"
$a1 = foreach ($server in $servers) {
[System.Net.Dns]::resolve($server)
}
After every command I have a list with 1-3 columns.
#NS
$a2 = foreach ($server in $servers) {
Resolve-DnsName -Name $server -Type NS -DnsOnly | select PrimaryServer, NameHost,NameExchange,Strings + $a3
}
#MX
$a3 = foreach($server in $servers) {
Resolve-DnsName -Name $server -Type MX -DnsOnly | select NameExchange
}
#TXT
$a4 = foreach($server in $servers) {
Resolve-DnsName -Name $server -Type TXT | select Strings
}
I receive this data:
HostName Aliases AddressList
-------- ------- -----------
google.com {} {172.217.22.46}
and this :
NameHost NameExchange
------------- --------
ns1.google.com
ns4.google.com
ns3.google.com
ns2.google.com
And the question is, How I can merge the to one big list with multiple columns?
P.s. Without using the PS-objects, because if I using it, I'm putting all data to 1 cell. I have the list with 3 columns, I need to add one more column with