If you maintain a legacy data warehouse, you probably have a scheduled task running right now that uses this driver. Treat it with respect. Document your connection strings. And for the love of data integrity, always add IMEX=1 when reading mixed data types.
$conn = New-Object System.Data.OleDb.OleDbConnection($connectionString) $conn.Open() $cmd = New-Object System.Data.OleDb.OleDbCommand($query, $conn) $reader = $cmd.ExecuteReader() microsoft access database engine 2010
while ($reader.Read()) { Write-Host "Region: $($reader['Region']) - Total: $($reader['TotalSales'])" } $conn.Close() If you maintain a legacy data warehouse, you
$connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Data\SalesReport.xlsx;Extended Properties='Excel 12.0 Xml;HDR=YES';" $query = "SELECT [Region], SUM([Sales]) as TotalSales FROM [Sheet1$] WHERE [Sales] > 1000 GROUP BY [Region]" Extended Properties='Excel 12.0 Xml