SQL Server 2008 Management Improvements – SQL Server Provider for PowerShell (Part 2)

At the SQL Connections conference in April of 2008 I gave a presentation on some of the new Manageability Improvements for SQL Server 2008. In this blog post I’ll talk about one of those new improvements – our new PowerShell provider for SQL Server.


Yesterday I posted about the basics of PowerShell. I mentioned that it has a few advantages that I think the DBA will find essential:


1.       It’s like a batch-file based system (all of your old logic will still work), but can work like a programming language as well

2.       It lets variables stand for objects (see the post yesterday for this)

3.       It has piping (the | symbol)


Let’s talk a little about that third item. You’ve probably used piping before – typing something like this:




Which just sends the list of files to the MORE command that shows a screen full of information at a time. Well, PowerShell has this capability as well. You can send the results of one action on one object to another action on yet another object. In fact, you can do that over and over until it gets a little confusing!


Let’s take a look at a simple example. Yesterday we tried this in PowerShell:


get-Content test.txt



In my simple file I have this:


This is a test.



Now let’s take that file, change some data,  and send it somewhere else:


(get-Content test.txt) –replace ‘test’, ‘not a test,’ | out-file new.txt


All we did here was open a file, replace some words, and send it to a new file. You can send lots of information from one side to another, and the important part to keep in mind is that you work from left to right – anything you end up with on the left side of the pipe is what you’re sending to the right side.


Tomorrow I’ll show you why this is really cool – we’ve created a way to work with SQL Server that will let you “lego-block” these command-lets and objects together in really powerful ways.

Comments (1)
  1. Have you ever seen or used the PowerShell? If so have you worked on PowerShell within SQL Server 2008,

Comments are closed.

Skip to main content