dns lookup script

Welcome Forums General PowerShell Q&A dns lookup script

This topic contains 2 replies, has 2 voices, and was last updated by

5 years ago.

  • Author
  • #15371

    Topics: 1
    Replies: 1
    Points: 0
    Rank: Member

    new to this board, saw on techED about this site. here is a small script i use to look up IP to DNS names:

    $Computerlist = get-content "./IPcomplist.txt"
    foreach ($i in $Computerlist){
    $rs = [System.Net.Dns]::GetHostbyAddress($i).HostName
    #FQDN driven
    #$rsIP = [System.Net.Dns]::GetHostAddresses($i)|select-object IPAddressToString -expandproperty  IPAddressToString
    $formatoutput = ($i + "," + $rs)
    write-output $formatoutput  |out-file Report_IP_FQDN.txt -append
    write-output "script has finished running"


  • #15372

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    And as a note to folks working on Windows Server 2012, Windows 8, or later, there's a native cmdlet that will do this also. See http://technet.microsoft.com/en-us/library/jj590781.aspx for Resolve-DnsName.

  • #15421

    Topics: 1
    Replies: 1
    Points: 0
    Rank: Member

    been playing with the new "resolve-dnsname" cmdlet, actually pretty nice. maybe I can not have to use dig so much now......

The topic ‘dns lookup script’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort