This script will output IP & Hostname in a CSV and will give a warning in the CLI upon failure (no DNS Record). Is it possible to also output the Failures to the CSV with the hostname defaulted to “Null”?

Essentially I want a complete CSV after a bulk DNS lookup including the failures. Any information for a PS Newbie will be appreciated.

get-content "C:\Users\xxx\yyy\ips.txt" | foreach-object {
  $ipAddress = $_
  try {
    [System.Net.Dns]::GetHostEntry($ipAddress) | select-object `
      @{Name = "IPAddress"; Expression = {$ipAddress}},
      HostName
  }
  catch [System.Management.Automation.MethodInvocationException] {
    write-warning "IP did not resolve - $ipAddress"
  }
} | export-csv "C:\Users\xxx\yyy\ReverseLookup.csv" -notypeinformation
3 Spice ups

sure, you can create a custom object and feed that with the fail / pass info.

In my experience exports by default dump everything in a CSV file. You have to then open the csv and clean it up.