PowerShell Script to Query Specified Columns of a .MDB DataBase

Script connects to the .MDB file using user DSN named “MS Access Database” pointing to the .MDB file and then queries the specified columns.

[code language=”powershell”]
$adOpenStatic = 3
$adLockOptimistic = 3
$userName = $env:USERNAME
$newDbPath = "C:\Temp\$userName\DPW"
$connectionString = "DSN=MS Access Database;"
$sourceQuery = "Select * From Connection"

$objConnection = New-Object -com "ADODB.Connection"
$objRecordSet = New-Object -com "ADODB.Recordset"

$objRecordset.Open($sourceQuery, $objConnection, $adOpenStatic, $adLockOptimistic)

While ($objRecordset.EOF -ne $True) {
ForEach ($column in "ConnectString", "FilePath", "BackupPath") {



Leave a Reply

Your email address will not be published. Required fields are marked *