PowerShell Answers

Adventures in PowerShell

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Don't show

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

PowerShell support in SQL 2008

I've just been looking at the PowerShell support and it looks interesting if a little limited - as has been stated in Dmitry’s PowerBlog.

You invoke PowerShell from SQL Server Management Studio by right clicking on a node in the tree and choosing 'Start PowerShell'. This runs 'SQLPS.exe' and starts the shell. One thing that caught me was that the resulting shell has some standard cmdlets missing. Add-PSSnapin, Get-PSSnapin, Remove-PSSnapin and Export-Console seem to have gone AWOL.

SQL Books Online states that the SQL snapins are

  • Microsoft.SqlServer.Management.PSProvider.dll
  • Microsoft.SqlServer.Management.PSSnapin.dll

As these are just regular snapins you can load them into the standard PowerShell host as follows -
First register the snapins using the .Net utility installutil with the commands

set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
cd "c:\Program Files\Microsoft SQL Server\100\Tools\Binn"
installutil Microsoft.SqlServer.Management.PSProvider.dll
installutil Microsoft.SqlServer.Management.PSSnapins.dll

and check that everything is OK


Registering SQL snapins

Then load the snapins

Installing the SQL snapins

and voila SQL support is enabled

SQL support working

Don't forget to remove and unregister (installutil /u) the snapins when you want to remove the CTP.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: PowerShell | SQL 2008
Posted by tb on Monday, February 25, 2008 1:23 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Saturday, July 05, 2008 4:42 AM