Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2771
  • Last Modified:

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

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
DetersLaw
Asked:
DetersLaw
  • 4
  • 2
1 Solution
 
BSonPoshCommented:
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
 
DetersLawAuthor Commented:
Thanks Bson!

I'll get back with you latr today after some testing.
0
 
DetersLawAuthor Commented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
BSonPoshCommented:
I think you could add that logic.
0
 
DetersLawAuthor Commented:
Thanks
0
 
metroexpertCommented:
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
 
DetersLawAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now