Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI Query with LIKE

Status
Not open for further replies.

Ravok

IS-IT--Management
Oct 12, 2006
2
IL
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
 
Should consult the documentation on MicrosoftDNS_AType class. It is a simple class with only ipaddress as its property. So you should simply do this?
[tt] Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top