Demo SQL Provider Code

Demo SQL Provider Code

Rate This
  • Comments 17

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.

Install the Snapin: 

PS>$env:Windir\Microsoft.NET\Framework\v2.0\.50727\InstallUtil.exe SQLProvider.dll

Add the snapin to your session:

PS>Add-PsSnapin SqlPrototypeProvider

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
EmployeeTerritories
Order Details
Orders
Products
Region
Shippers
Suppliers
Territories

SQL:>cd Employees

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

EmployeeID      : 8
LastName        : Callahan
FirstName       : Laura
Title           : Inside Sales Coordinator
TitleOfCourtesy : Ms.
BirthDate       : 1/9/1958 12:00:00 AM
HireDate        : 3/5/1994 12:00:00 AM
Address         : 4726 - 11th Ave. N.E.
City            : Seattle
Region          : WA
PostalCode      : 98105
Country         : USA
HomePhone       : (206) 555-1189
Extension       : 2344
Photo           : {21, 28, 47, 0...}
Notes           : Laura received a BA in psychology from the University of Washington.  She has also completed a course
                   in business French.  She reads and writes French.
ReportsTo       : 2
PhotoPath       : http://accweb/emmployees/davolio.bmp

 Wassim [MSFT]

 

 

Attachment: SQLProvider.zip
Leave a Comment
  • Please add 5 and 2 and type the answer here:
  • Post
  • Hi Wassim,

    Cool code. I was wondering, is there anything similar for browsing an object graph/hierarchy, I mean generically? Say I have a Customer object that has an Orders property. Is there a PowerShell provider that allow me to do, for example:

    cd MyModel:

    cd Customers

    cd "John Doe"

    cd Orders

    dir *.Paid.*

    ? I thought this would be generic enough to be available right off the box, but I can't find a way to do it? Should I write my own code for this?

    Thanks anyway :-)

  • "The authentication is done on the SQL server. I did not add any credential parameter."

    how could I add a credential parameter?

    Thanks

    Jason S

Page 2 of 2 (17 items) 12