I have a simple script that accesses a Microsoft ACCESS database using the so-called OleDB and ACE drivers. It works fine in Win 7 (64-bit) in PS 5.1 (ISE). When I ported the script to Win10 (64-bit), I also got it to work in PS 5.1/ISE. I installed the ACE module successfully in PS Core with the command:
Install-module -name ACE
followed by
GCM -module ACE
to verify the Get-ACEData cmdlet is now installed.
Also, I reinstalled on the Win10 PC (as part of the effort to make it work in Win PS 5.1/ISE) the required software - Microsoft Access Database Engine 2010 Redistributable (64-bit).
But when I ran the script in VS Code/PS Core, I got the error message:
Cannot find type [Data.OleDb.OleDbConnection]: verify that the assembly containing this type is loaded.
This is clearly attributable to the 2nd line in the initialization statements in the script:
$connStr="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$AccessFile;Persist Security Info=False" $conn = New-Object Data.OleDb.OleDbConnection($connStr) $conn.open()
I’d be grateful for any tips or guidance why this is happening in VS Code/PS Core, but not in WinPS 5.1 ISE. Sincere thanks.