Wednesday, February 20, 2008 - Posts

Start PowerShell in Management Studio

In the February CTP of SQL Server 2008 a new feature has appeared in SQL Server Management Studio. You now have the ability to right-click on an object in the Object Explorer window and open up a PowerShell window. In this window you can navigate the database structures much like you can a disk file subsystem, or like you can navigate the registry in PowerShell.

So, let's say you right-click on your server name and open up a PowerShell window. You can then issue the command:

cd Databases/AdventureWorks

Now you're pointing to the AdventureWorks database. Using PowerShell in this way allows you to browse the Server Management Objects (SMO) tree structures. (By the way, you'll have to remember to use proper case when browsing the SMO objects. They are case-sensitive in this environment.) Now, you can type this:

dir Tables

What returns is a list of the tables in AdventureWorks. It's kind of neat idea, and definitely fun to play with. I haven't found a productive use for it yet, but it's too new for me to make a judgement yet. I like it, but I don't yet know why.

Let me know what you think.

Allen




Cross-posted from SQLBlog! - http://www.sqlblog.com