Mark Minasi's Tech Forum
Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
wobble_wobble

Avatar / Picture

Associate Troublemaker Apprentice
Registered:
Posts: 910
Reply with quote  #1 
Trying to write the output of the command Resolve-DnsName -Name abc.com
to a txt/csv file without the headers.


PS C:\> Resolve-DnsName -name mjf.ie | Select-Object name,type,IPAddress

Name Type IPAddress
---- ---- ---------
abc.com A 199.181.132.250



when I try to writ the output to a txt file, I get the headers.
Tried the following different options


$dnsnames =  Get-Content "E:\dns\dummydns.txt"
foreach ($name in $dnsnames){
echo $name A >>"E:\dns\dnsoutput-demo.csv"
Resolve-DnsName -Name $name -Type A  >>"E:\dns\dnsoutput-demo.csv"
Resolve-DnsName -Name $name -Type txt >>"E:\dns\dnsoutput-demo.csv"
# 0 Resolve-DnsName -Name $name | Select-Object -Property  name,type,IPAddress | out-file -append -filepath "E:\dns\dnsoutput-demo.csv"
# 1 Resolve-DnsName -Name $name | Select-Object -Property name,type,IPAddress | out-file -append -filepath "E:\dns\dnsoutput-demo.csv"
# 2 Resolve-DnsName -Name $name | Select-Object -Property name,type,IPAddress | Export-Csv -append -path "E:\dns\dnsoutput-demo.csv"
# 3 Resolve-DnsName -Name $name -Type txt >>"E:\dns\dnsoutput-demo.csv"
echo "Next Entry" | out-file -append -filepath "E:\dns\dnsoutput-demo.csv"
}


Anyone know how I can just get the output of the name,type,IPAddress or individually...


__________________
Have you tried turning it off and walking away? The next person can fix it!

New to the forum? Read this
0
lady_mcse

Avatar / Picture

Senior Member
Registered:
Posts: 109
Reply with quote  #2 

How about this?

Resolve-DnsName -name mjf.ie | Select-Object name,type,IPAddress | export-csv filename.csv -NoTypeInformation


Assuming you don't mind column headings, but you do mind the "#TYPE Selected.Microsoft.DnsClient.Commands.DnsRecord_AAAA" is what you're looking to get rid of, then I think this should work.

0
wobble_wobble

Avatar / Picture

Associate Troublemaker Apprentice
Registered:
Posts: 910
Reply with quote  #3 
Thanks
Looks better than what I had.
Some day I'll do a coding class

__________________
Have you tried turning it off and walking away? The next person can fix it!

New to the forum? Read this
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.