Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old January 11th, 2008, 12:13 PM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Novice (500 - 999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 969 keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 3 h 4 m 57 sec
Reputation Power: 280
Send a message via Yahoo to keep_it_simple
Query exchange server w/ WQL and Like/wilcard

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 MailboxDisplayName = 'joe'")


    for each objItem in colItems

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

 results.innerhtml = sResults

Reply With Quote
  #2  
Old January 12th, 2008, 06:18 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 675 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Days 18 h 35 m 6 sec
Reputation Power: 308
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
WQL does support the LIKE keyword, but only if you use it correctly. The syntax in your match statement is wrong. Refer to the WQL Reference for usage information.
vb Code:
Original - vb Code
  1. Set colItems = objWMIService.ExecQuery( _
  2.     "SELECT * FROM Exchange_Mailbox WHERE MailBoxDisplayName LIKE '%joe%'")
You are correct, LIKE is only available on Windows XP and newer.
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
  #3  
Old January 13th, 2008, 11:33 AM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Novice (500 - 999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 969 keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 3 h 4 m 57 sec
Reputation Power: 280
Send a message via Yahoo to keep_it_simple
Quote:
Originally Posted by Nilpo
WQL does support the LIKE keyword, but only if you use it correctly. The syntax in your match statement is wrong. Refer to the WQL Reference for usage information.
vb Code:
Original - vb Code
  1. Set colItems = objWMIService.ExecQuery( _
  2.     "SELECT * FROM Exchange_Mailbox WHERE MailBoxDisplayName LIKE '%joe%'")
You are correct, LIKE is only available on Windows XP and newer.


sorry nilpo...i posted the wrong code..that one was an "experiment"/debug and i should have caught that to eliminate the obvious....i am using like with %

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


any other way to query exchange? i'm trying to query for only particular recs....i can use w/o a where clause and use instr in the looped recordset to get the recs needing...however...i'd rather use a select qry that returns 14 recs vs 2000+...any other method besides WbemScripting.SWBemlocator?....

i don't have access att...but i have not tried a .vbs vs .hta i'm doing now......i don't see how this would change because of .hta unrestrictions....any thoughts?

i was hoping you'd pop in

thanks for your time

Last edited by keep_it_simple : January 13th, 2008 at 11:44 AM.

Reply With Quote
  #4  
Old January 13th, 2008, 04:47 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 675 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Days 18 h 35 m 6 sec
Reputation Power: 308
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
Quote:
Originally Posted by keep_it_simple
i was hoping you'd pop in
I haven't had as much time to just browse the forums lately, unfortunately. However, I subscribed to the Windows Scripting forum so a thread here will generally get my attention.

If your query is ok, then it may be something altogether different. You were asking about another method as opposed to using WbemScripting.SWBemlocator. Yes, there is. You can connect to WMI directly instead. Let me double check a few things with regards to Server 2003.

I'll post back with some alternative code for you to try. I'll add some error-handling so we can have a little better idea where it's bugging out. Unfortunately, without access to your Exchange server I can't test the code myself. But I'm sure with a little patience, we'll get it.

Reply With Quote
  #5  
Old January 13th, 2008, 04:50 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 675 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Days 18 h 35 m 6 sec
Reputation Power: 308
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
Looks like you've got a thread going about this on Tek-Tips too.

Do us favor and post a reply here if you do manage to get a solution there.

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Query exchange server w/ WQL and Like/wilcard


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway