Forum Discussion

vishwas_n's avatar
vishwas_n
Occasional Contributor
12 years ago

IP Address fetching for remote machine using C#Script

Fellas, Am using this piece of code to fetch the IP ... wmiServ["ExecQuery"]("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"); Which is returnin...
  • TanyaYatskovska's avatar
    12 years ago

    Hi Vishwas,


     


    The following code, posted in this thread, works for me:




    Sub LogIPAddress 


      strQuery = "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True" 


      Set colItems = GetObject("winmgmts:").ExecQuery(strQuery) 


      Log.Message sys.HostName 


      For Each objItem In colItems 


        Log.Message(objItem.DNSHostName) 


        Log.Message(objItem.IPAddress(0))  


      Next  


    End Sub 




     


    If it doesn't work, check the WMI settings on the computer.