Powershell – Find the name servers for a list of domains and spit the results to CSV

Change the path of $list to the path of your text file with the domains. The domains need to be one per line in the text file. Change the?$exportPath to where you want to save the CSV file. Then copy and paste the code below into a .ps1 file and run from PowerShell.

$list = “C:\meh\Domains.txt”
$exportPath = “C:\meh\meh.csv”
$apps = get-content $list

$nsresults = @()
foreach ($app in $apps) {
$nsresults += Resolve-DnsName -Type 2 -Name $app | select -first 1 Name, NameHost
$nsresults | Export-Csv -Path $exportPath

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.