Jump to content

DNS Server IP


Go to solution Solved by jguinch,

Recommended Posts

GUICtrlSetData($Output, "Computer Name: "& $strComputer & @CRLF & _
        "DNS Server: "& $objAdapter.DNSServerSearchOrder(0) & @CRLF & _
        "                          "& $objAdapter.DNSServerSearchOrder(1) & @CRLF & _
        "                          "& $objAdapter.DNSServerSearchOrder(2) & @CRLF & _
        "                          "& $objAdapter.DNSServerSearchOrder(3))

Maybe some one could help me out with this.This works were it grabs a remote machine DNS IPs and outputs it into a editbox. But the issue is, if there isn't lets say a 4th DNS IP the script doesnt work properly. How could I change it so if there no DNS IP to just show up with no info?

Link to comment
Share on other sites

    you could check how many elements are In the $objAdapter.DNSServerSearchOrder collection like this :
  

$elements = UBound($objAdapter.DNSServerSearchOrder)

    And then loop only the existing elements like this

For $i = 0 To $elements - 1
        ConsoleWrite($objAdapter.DNSServerSearchOrder($i) & @CRLF)
    Next

... then it's up to you to take care of the aesthetic formatting inside the EditBox

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • Solution

Maybe something like this :

$sDnsSearchOrder = ""

For $i = 0 To $elements - 1
    $sDNS = $objAdapter.DNSServerSearchOrder($i)
    If $sDNS = "" Then ExitLoop
    
    $sDnsSearchOrder &= $sDNS & @CLRF
Next

GUICtrlSetData($Output, "Computer Name: "& $strComputer & @CRLF & _
        "DNS Server: "& $sDnsSearchOrder)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...