Solved

Using Powershell to add/update records in an Microsoft Access db

Posted on 2008-10-15
7
2,036 Views
Last Modified: 2011-10-03
Powershell newbie here.

I have a simple powershell script that collects the hardware inventory of a machine, including the serial number.  I'd like to add some code to my script that puts the results in a single MS Access database, so that there is only one db record maintained per serial number.

Thanks!
0
Comment
Question by:DetersLaw
  • 4
  • 2
7 Comments
 
LVL 18

Accepted Solution

by:
BSonPosh earned 250 total points
ID: 22727927
Here is a link that explains exactly what your looking for
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0115.mspx

There is another article written by a Powershell Dev that directed at SQL, but works for Access as well
http://www.leeholmes.com/blog/InteractingWithSQLDatabasesInPowerShellInvokeSqlCommand.aspx

0
 

Author Comment

by:DetersLaw
ID: 22730774
Thanks Bson!

I'll get back with you latr today after some testing.
0
 

Author Comment

by:DetersLaw
ID: 22730999
The script at TechNet is very close.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan08/hey0115.mspx

But each time that script is run, it adds a new record.  I'd like something that checks for the existence of the serial number and then updates that record if it exists.  If the serial number does not exist in the db, then add a new record.  IOW, I don't want multiple records for the same serial number.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 18

Expert Comment

by:BSonPosh
ID: 22731423
I think you could add that logic.
0
 

Author Closing Comment

by:DetersLaw
ID: 31506504
Thanks
0
 

Expert Comment

by:metroexpert
ID: 22908282
Was this solved because I need to update a SQL 2000 record base on a name but i dont want to add a new record. Can someone give me the update code. thanks
0
 

Author Comment

by:DetersLaw
ID: 22923559
We set a field in our Access 2k3 database to be indexed, allowing no duplicates.  Our Powershell script needed a line of code (below) so users wouldn't see the ugly errors when it tries to add a new record.  A powershell update code would be perfect, but this works well for us.

$erroractionpreference = "silentlycontinue"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now