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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to query exchange server with WQL and like/wildcard

Status
Not open for further replies.

bslintx

Technical User
Apr 19, 2004
425
US
ok, i'm at wits end here

i am trying to query exchange server using like, however i receive "Could not complete operation due to error 80041024"

this is the code that has the error:

Code:
 Set SWbemLocator = CreateObject("WbemScripting.SWBemlocator")
     Set objWMIService = SWBemlocator.ConnectServer _
         ("excchangeserver123", "root\MicrosoftExchangeV2","Domain\admin","123456789")


     Set colItems = objWMIService.ExecQuery("SELECT * FROM Exchange_Mailbox WHERE MailBoxDisplayName LIKE 'joe*'")


    for each objItem in colItems

      
         sResults = sResults & objItem.MailboxDisplayName & " " &  objItem.StoreName & "<br>"
        
        
       
   next

 results.innerhtml = sResults

every google query i came upon when using the like statement and WQL(sql subset) needs to be xp...i have xp pro and server is 2003....i am totally lost as this code is presented everywhere but i am having problems tracking down the mistake...please advise...i'm going nuts

code that does work with where statement but w/o like

Code:
 Set SWbemLocator = CreateObject("WbemScripting.SWBemlocator")
     Set objWMIService = SWBemlocator.ConnectServer _
         ("excchangeserver123", "root\MicrosoftExchangeV2","Domain\admin","123456789")


     Set colItems = objWMIService.ExecQuery("SELECT * FROM Exchange_Mailbox WHERE ServerName = 'joe'")


    for each objItem in colItems

      
         sResults = sResults & objItem.MailboxDisplayName & " " &  objItem.StoreName & "<br>"
        
        
       
   next

 results.innerhtml = sResults
 
forgot to mention...it's a .hta....i'm sure that was inplied w/ the innerhtml but just in case...thanks
 
Did you try using % instead of * ?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
unfortunately yes...i can't for the life of me understand why it doesn't work....if someone has successfully ran the like in this situation...please let me know....it would be appreciated....

btw....i can obviously grab all mailboxes (2000+) in this case and loop with an instr but i'd rather return only the records i need and loop 14 vs 2000+
 
also...the * was the wrong one posted ...all demos used %...it just happened to be the last one i was experimenting with on a copy/paste/post...good eye dm4ever
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top