How to get ip address of Remote machine using windowsmanagement class or Win32


We can get ip address of remote machine easily,but some time we cant all ip address on remote.now we will see how to get all ip address of Remote machine?

We can get ip address of remote machine easily,but some time we cant all ip address on remote. Now we will see how to get all ip address of Remote machine?

 
string getIP(string strServerName)
{
string ip = string.Empty;
string ip1 = string.Empty;
string IPFinal = string.Empty;
ArrayList collectIPlast = new ArrayList();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject mo in queryCollection)
{
string[] addresses = (string[])mo["IPAddress"];
foreach (string ipaddress in addresses)
{
collectIPlast.add(ipaddress.ToString());
}
}
}


Related Articles

More articles: Get IP address IP address Win32

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: