Solved

Using MS Powershell to Query MS Access with Complex SQL Query

Posted on 2008-10-30
1
566 Views
Last Modified: 2013-12-22
Hello,

I am trying to query an MS Access DB from a PowerShell script using a fairly routine SQL statement and am running into a strange error.  I am using the methodology outlined here:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0115.mspx

Which works fine for a standard SQL query.  But I want to use a WHERE statement in my query.  So line six would look like:

$objRecordset.Open("Select * From Computers WHERE operating_system = 'Windows XP'", $objConnection,$adOpenStatic,$adLockOptimistic)

But when I execute this line in PowerShell I get an error stating that the function call cannot accept five parameters.  Unfortunatly nothing I try helps me get around this issue.  I've tried -eq in place of the equals sign, placing the SQL in parentheses, etc and had no joy.

Does anyone know how to get around this issue?

Thank you!
0
Comment
Question by:bgsullivan
1 Comment
 
LVL 18

Accepted Solution

by:
BSonPosh earned 500 total points
ID: 22844377
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question