> I want to resolve the name of a computer on the network from it's IP address.
> I'm using WMI Win32_PingStatus with the name of the computer to get it's IP
> address and now want to resolve that IP address just like the command ping
> -a does.
Sorry if I misunderstood what you need, but if you don't know the name of a
remote computer, you can use IP address to connect to WMI on that computer
and get it's name with Win32_Computersystem.Name
strComputer = "192.168.5.7"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
WScript.Echo objComputer.Name
Next
--
urkec
That way i know which computers i have to check.
> My problem is that there are doubles of the computer name on the network.
> May be a mixup in the DNS, but what ever teh reason, i want to check for
> these doubles.
> The way we do that now is as follow:
> 1- ping one computer by it's name: "ping MyComputer" which gives the IP
> Address "12.12.12.12"
> 2- resolve the IP address to check what's in the DNS: "ping -a 12.12.12.12",
> which gives the name of the other computer "TheOtherComputer"
>
> That way i know which computers i have to check.
>
>
Maybe you could use Win32_NetworkAdapterConfiguration.DNSHostName:
strComputer = "192.168.5.7"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration " _
& "Where IPEnabled = True")
For Each objComputer in colComputers
WScript.Echo objComputer.DNSHostName
Next
Or you could just use WshShell.Exec to automate what you are doing now.
--
urkec
I ran into this when I started doing things on remote hosts also. If
you compile a list of computers you want to check, run the wmi query
against that computer to find the computername, if the two do not
match its a bad host record, else the host you resolved to matches the
wmiquery computername. Hope that helps.