JustScriptIt
Technical User
I am writing a script such that, it will display computer name based on IP address
However, when I do
ping -a IP Address
on the same command prompt where I executed this script, I get an entirely different computer name.
I notice this for several computers.
What is the most reliable way to display the computer name, based on IP address.
NOTE: We use dynamic DHCP servers that renews IP addresses ever few days, but this comparison was done within minutes.
Code:
Set objWMISvc = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", ,48 )
For Each objItem in colItems
strComputerDomain = objItem.Domain
Next
However, when I do
ping -a IP Address
on the same command prompt where I executed this script, I get an entirely different computer name.
I notice this for several computers.
What is the most reliable way to display the computer name, based on IP address.
NOTE: We use dynamic DHCP servers that renews IP addresses ever few days, but this comparison was done within minutes.