Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-15
7
Medium Priority
?
2,663 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 1000 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

963 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