nslookup++ / How to Resolve a List of Hostnames to a List of IPs...

...with access to the DOS command prompt commands and the bare minimum set of PowerShell cmdlets.

Copy and paste the script below into a text editor and save as say nslookup++.ps1, and run in PowerShell as .\nslookup++.ps1.

Example image of it in use is below (using public website addresses since cannot share internal hostnames on this blog.)

Image: Example of nslookup++ in action

The Script

[Boolean]$Repeat = $TRUE
  Write-Host "nslookup++: RESOLVES LIST OF HOSTNAMES TO IP"
  Write-Host "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  Write-Host "Enter list of hostnames (can paste a list)"
  Write-Host "  and press ENTER on empty line to continue (no input terminates program):"
  [System.Array]$Hosts = @()
  [Boolean]$do = $TRUE
    $ReadIn = Read-Host
    If($ReadIn -eq ""){$do = $FALSE}
    else{$Hosts += $ReadIn}
  [System.Array]$HostsOut = @()
  $Hosts | Foreach{
    If($_ -eq "NONE"){$HostsOut += "NO CHECK"}
      [System.Array]$nslookup = (nslookup $_)
      [Int32]$TempCount = 0
      [String]$Result = ""
      Foreach($line in $nslookup){
          $Result = $nslookup[$TempCount].Split(" ")[2]
      If(!$Result){$HostsOut += "DNF"}
      else{$HostsOut += $Result}
  $HostsOut | Foreach{Write-Host $_}
  If($Hosts.count -eq 0){$Repeat = $FALSE}