DetersLaw
asked on
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!
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
I think you could add that logic.
ASKER
Thanks
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
ASKER
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"
$erroractionpreference = "silentlycontinue"
ASKER
I'll get back with you latr today after some testing.