The goal of PsAdoNet is to encourage the development of composeable ADO.NET solutions using PowerShell. Adhering to Powershell's core philosophy of doing one thing and doing it well, the steps of interacting with a data source are broken into small tools, as opposed to a single-serving function.
# Installing for a specific user
Copy-Item -Path {rest of path}\PsAdoNet `
-Destination $HOME\Documents\PowerShell\Modules
# Close & re-open shell window
# Verify it worked
Get-Command -Module PsAdoNet
For more detail installation instructions see the official docs
A simple example demonstrating the execution of a simple query against a SQL Server Instance.
# Create a DbConnection
$conn = New-SqlServerConnection -ServerInstance SQLVM01
# Create a DbCommand
$cmd = New-DbCommand -Query "SELECT * FROM Products"
# Invoke query and display result
$cmd | Invoke-DbCommand | Format-Table
# Properly dispose of objects
Close-Resource $conn, $cmd
An example demonstrating efficient and practical ETL pattern using SqlBulkCopy
and an IDataReader
.
$source = New-SqlServerConnection -ServerInstance SQLVM01 -Database Northwind
$dest = New-SqlServerConnection -ServerInstance SQLVM02 -Database Northwind
$rd = $source | New-DbCommand -Query "SELECT * FROM Products" | Invoke-DbCommand -Reader
$bcp = Invoke-SqlServerBulkCopy $rd -Connection $dest -Table "Products" -BatchSize 5000 -BulkCopyTimeout 30
Close-Resource $source, $dest, $rd, $bcp
There's an issue for that.
Built with ♥ by Pim Brouwers in Toronto, ON. Licensed under Apache License 2.0.