Use ADO to connect to a Microsoft Access database from PowerShell. In order to do this you may have to download “Microsoft Access Database Engine 2010.” If you have 32-bit MS Office installed you will have to install the 32-bit engine. Likewise, you will have to run PowerShell in 32-bit mode.
First we set these two variables to set the cursor type and record locking method used
adLockOptimistic - Indicates optimistic locking, record by record. The provider uses optimistic locking, which locks records only when you call the Update method.
adOpenStatic - Uses a static cursor, which is a static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.
Next we create objects for ADODB.Connection and ADODB.Recordset. These objects will be used for the connection to the database itself and the set of records we want to work with.
Now we will use the $conn object to connect to the database.
Now that we have a connection set we can select the records we want to work with.
Once the recordset is created we can read whats in it.
Or we could add a new record
Close the connection and recordset when you’re done.