Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

analyze Access accdb files

$
0
0

I've been given a project to interrogate Access databases for external database connections. This would mean looking through the modules and and External Data connections, and output my findings to a CSV file.

I'm able to find the ACCDB files, I'm able to open them just fine, but I can't seem to browse through the Module file. My code is below. I'm unclear as to how to cycle through the Properties of a module, as it returns "System.__ComObject" and I didn't find much documentation to help me evaluate that. I looked through the Access object model library (https://msdn.microsoft.com/en-us/library/office/ff192120.aspx) but that only took me so far.

Any help would be greatly appreciated.

Andre

 

 

$env:Path = "C:\Development\DataConnectionPowerShell";

$DatabasePath = "$env:Path\TestAccess.accdb"

# https://social.technet.microsoft.com/Forums/en-US/654e81a7-e998-4575-9261-ad4d2507117a/how-to-invoke-ms-access-vba-function?forum=winserverpowershell

$acc = New-Object -ComObject Access.Application

$acc.OpenCurrentDatabase($DatabasePath)

 

            if (1 -eq 0) {

                # works

                $acc.CurrentProject | Select-Object *

                $acc.CurrentProject.AllModules | Select-Object *

            }

 

foreach ($accModule in $acc.CurrentProject.AllModules) {

    $accModule.Name

    $accModule | Select-Object *                      # works !

    $accModule | Get-Member                           # works !

    Write-Output "...."

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles