Thursday, June 21, 2007

SQL Server Provider/Namespace for PowerShell (Think "Easy Command Line/PowerShell Access to SQL Server Data")

Windows PowerShell - Demo SQL Provider Code

"Hi,

Attached is the code we used today in the Web cast for the SQL demo provider. Please note this is not a SQL management provider. It simply allows you to query data from a SQL server directly from the cmd line.

...

You can use it as follows:

PS>cd SQL:
SQL:>cd MySQLServer
SQL:>dir

master
tempdb
model
msdb
pubs
Northwind

SQL:>cd Northwind
SQL:>dir

name
----
Categories
CustomerCustomerDemo
CustomerDemographics
Customers
dtproperties
Employees
...

SQL:>cd Employees
SQL:>Dir -filter {where EmployeeId=8}

EmployeeID      : 8
LastName        : Callahan
FirstName       : Laura
Title           : Inside Sales Coordinator
TitleOfCourtesy : Ms.
..."

Nice. I've been thinking about something like this since this post, Provider Explorer in PowerShell Analyzer.

The C# source is also provided.  :)

 

Related Past Post XRef:
Provider Explorer in PowerShell Analyzer

No comments: