I'm trying to write a wmi query that will resolve a host.
The person who will search for the host might not know the full name of the host.
The script bellow was checked on Windows 2003 server.
I am basing my syntax on:
If the query was:
Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType where OwnerName = 'name.domain.com'")
it would work.
The query from the script doesn't work, anyone has any idea why?
If you could show me an other way it would be good too for me just bare in mind that enumerating the entire domain takes about 12seconds and will grow over time which is not acceptable by the person who needs the script.
The script:
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\MicrosoftDNS")
Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType where OwnerName LIKE 'name%'")
For Each objItem in colItems
Wscript.Echo "IP Address: " & objItem.IPAddress
Next
The person who will search for the host might not know the full name of the host.
The script bellow was checked on Windows 2003 server.
I am basing my syntax on:
If the query was:
Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType where OwnerName = 'name.domain.com'")
it would work.
The query from the script doesn't work, anyone has any idea why?
If you could show me an other way it would be good too for me just bare in mind that enumerating the entire domain takes about 12seconds and will grow over time which is not acceptable by the person who needs the script.
The script:
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\MicrosoftDNS")
Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType where OwnerName LIKE 'name%'")
For Each objItem in colItems
Wscript.Echo "IP Address: " & objItem.IPAddress
Next