Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resolving PC Name from IP Address

1,791 views
Skip to first unread message

Gilbert_Voyer_Montréal

unread,
Sep 26, 2007, 11:26:00 AM9/26/07
to
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 juste like the command ping
-a does.
By default, the property ResolveAddressNames is set to false.
I was wondering if there was a way to set that to true, because i believe
that this option will "ask" to resolve similaraly to the -a option of the
ping command.

urkec

unread,
Sep 26, 2007, 2:12:01 PM9/26/07
to
"Gilbert_Voyer_Montréal" wrote:

> 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

Gilbert_Voyer_Montréal

unread,
Sep 26, 2007, 3:00:07 PM9/26/07
to
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.

urkec

unread,
Sep 26, 2007, 3:44:01 PM9/26/07
to
"Gilbert_Voyer_Montréal" wrote:

> 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

JakeDAHS

unread,
Sep 26, 2007, 4:35:24 PM9/26/07
to

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.

-J
www.pooradmin.com


0 new messages