kAccess – Read and Write Access Databases from PowerShell 7 on Any Computer
A PowerShell tool by Peter Kalmström
Many companies still keep important data in Access files: price lists, customer registers, back ends of old applications. Reading them from a script has always meant installing Access or the Access Database Engine on a Windows computer, and choosing between the 32-bit and 64-bit driver.
With the free kalmstrom.com module kAccess, a PowerShell 7 script opens the file directly, also on a Linux server, in a container or in an Azure Function.
kAccess is often used to:
move the data in an Access file to SharePoint or an SQL database.
export Access tables to CSV or JSON every night.
fill a database that an Access front end then uses.
create a new, clean test database each time a test runs.
In the demo below Peter Kalmström installs kAccess in PowerShell 7 on Windows, runs the sales database example and then opens the same file in Microsoft Access: both tables, the 300 orders and the relationship are there.
What kAccess gives your scripts
No drivers at all: kAccess is written in pure PowerShell and reads the Access file format itself. Nothing is installed except the module.
Any platform: the same script runs on Windows, Linux and macOS, so Access data can be part of automation that does not run on a desktop.
Real objects: every row comes back as a PowerShell object with one property per column, so you can use Where-Object, Sort-Object, Export-Csv and ConvertTo-Json as usual.
Full writing: add, change and delete rows. AutoNumber columns get their next number, and primary keys and unique indexes are kept up to date and checked.
Fast bulk writes: rows piped to Add-kAccessRow are written together with one index update – 500 rows into an indexed table take a few seconds.
Safe writes: all rows are checked before anything is written. When one row is refused, for example by a duplicate key, nothing is written at all.
New databases: create .accdb files (Access 2007 to 2019) or .mdb files (Access 2000 and 2003) with tables, indexes, a primary key and relationships, and open them in Access afterwards.
Install and use kAccess
The Install and use kAccess page shows the installation, your first database and the seven ready-made example scripts that come with the module. The kAccess manual has all the commands.
Good to know
Relationships are created without referential integrity: Access shows the join line, but it is not enforced.
Queries, forms and reports are not read or written – kAccess works with the tables.
When a table is deleted, Access frees its space the next time you run Compact & Repair.
kAccess is a PowerShell port of the open source Java library Jackcess. Every part of it has been checked by letting Jackcess read the files
kAccess writes.