<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Michiel Wories' WebLog : Powershell</title><link>http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx</link><description>Tags: Powershell</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>PowerShell Tips &amp; Tricks: Getting more detailed error information from PowerShell</title><link>http://blogs.msdn.com/mwories/archive/2009/06/08/powershell-tips-tricks-getting-more-detailed-error-information-from-powershell.aspx</link><pubDate>Mon, 08 Jun 2009 18:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9708370</guid><dc:creator>mwories</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwories/comments/9708370.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=9708370</wfw:commentRss><description>&lt;P&gt;Allen White wrote this handy blogpost on how to handle error message and get more information out of an error record:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/allen_white/archive/2009/06/08/handling-errors-in-powershell.aspx" mce_href="http://sqlblog.com/blogs/allen_white/archive/2009/06/08/handling-errors-in-powershell.aspx"&gt;http://sqlblog.com/blogs/allen_white/archive/2009/06/08/handling-errors-in-powershell.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;There is an addtional method to get more information available. I found myself sending this little code snippet in email to many, and almost always I get the response that it saved that person with a ton of work, as new users to PowerShell are often left bewildered by the sparse error information; I had colleagues grabbing for the debugger to find the more detailed error messages...&lt;/P&gt;
&lt;P&gt;An example; let's generate a simple error (recreate master will not work on most systems):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;$db = new Microsoft.SqlServer.Management.Smo.Database&lt;BR&gt;$db.Name = "master"&lt;BR&gt;$db.Parent = get-item .&lt;BR&gt;$db.Create()&lt;BR&gt;Exception calling "Create" with "0" argument(s): "Create failed for Database 'master'. "&lt;BR&gt;At line:1 char:11&lt;BR&gt;+ $db.Create( &amp;lt;&amp;lt;&amp;lt;&amp;lt; )&lt;BR&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not very helpful is it?&lt;/P&gt;
&lt;P&gt;Here is where this little gem comes in:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;$error[0]|format-list -force&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now let's take a look at the details this emits:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Exception&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: System.Management.Automation.MethodInvocationException:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exception calling "Create" with "0" argument(s): "Crea&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; te failed for Database 'master'. " ---&amp;gt; Microsoft.SqlSe&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rver.Management.Smo.FailedOperationException: Create fa&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iled for Database 'master'.&amp;nbsp; ---&amp;gt; Microsoft.SqlServer.M&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; anagement.Common.ExecutionFailureException: An exceptio&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n occurred while executing a Transact-SQL statement or &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; batch. ---&amp;gt; System.Data.SqlClient.SqlException: Databas&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e 'master' already exists. Choose a different database &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlConnection.OnError(SqlEx&lt;BR&gt;&lt;EM&gt;&amp;lt;cutting middle part out&amp;gt;&lt;BR&gt;&lt;/EM&gt;TargetObject&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;BR&gt;CategoryInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : NotSpecified: (:) [], MethodInvocationException&lt;BR&gt;FullyQualifiedErrorId : DotNetMethodTargetInvocation&lt;BR&gt;ErrorDetails&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;BR&gt;InvocationInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : System.Management.Automation.InvocationInfo&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;Well, now THAT's more like it!&lt;/P&gt;
&lt;P mce_keep="true"&gt;As you can see the -force flag does a couple of nice things.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;It concatenates the error messages into a somewhat understandable result.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;It dumps stack information + all other error information avalable.&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;Generally it's a time saver as you have this command readily available for you at the command line.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Do you have any tips on error handling? I'd love to hear about it.&lt;/P&gt;
&lt;P mce_keep="true"&gt;-Michiel&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9708370" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>Talking about SQLPS (SQL Server Powershell extensions) on Runas Radio</title><link>http://blogs.msdn.com/mwories/archive/2008/09/24/talking-about-sqlps-sql-server-powershell-extensions-on-runas-radio.aspx</link><pubDate>Wed, 24 Sep 2008 20:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8963907</guid><dc:creator>mwories</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwories/comments/8963907.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=8963907</wfw:commentRss><description>&lt;P&gt;I was recently interviewed on RunAs Radio on the new Powershell extensions that we developed for SQL Server 2008.&lt;/P&gt;
&lt;P&gt;If you want to learn more about SQL Server Powershell download the podcast here : &lt;A href="http://www.runasradio.com/default.aspx?showNum=75"&gt;http://www.runasradio.com/default.aspx?showNum=75&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you listened to it then please post your feedback here.&lt;/P&gt;
&lt;P&gt;Happy listening!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8963907" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>What? No cmdlets? -- SQL Server Powershell</title><link>http://blogs.msdn.com/mwories/archive/2008/06/25/what-no-cmdlets-sql-server-powershell.aspx</link><pubDate>Wed, 25 Jun 2008 10:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8651649</guid><dc:creator>mwories</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwories/comments/8651649.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=8651649</wfw:commentRss><description>&lt;P&gt;When you start using the SQL Server Powershell extensions, you will find there are not a whole lot of cmdlets. The expectation is indeed that Powershell support means: cmdlets for every administrative operation you can perform. Did we miss something here? Nope, this is by design. We &lt;U&gt;do&lt;/U&gt; intend to ship more cmdlets for common admin tasks, but our first goal was to unlock as many Object Models as we could in the first release.&lt;/P&gt;
&lt;P&gt;We did provide some basic cmdlets to start you off with. We know that DBA's willl have tons of T-SQL scripts that they will not abandon immediately in favor of Powershell. These scripts can be integrated with Invoke-Sqlcmd. We also provided a cmdlet to evaluate Policies, something that will come in handy if you have a lot of servers to manage (see one of my previous posts that contains a reference to an excellent blog entry from Lara on this subject).&lt;/P&gt;
&lt;P&gt;Right now you will find that you can navigate to four different object models:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SQL Server Relational Managenent Objects (SMO)&lt;/LI&gt;
&lt;LI&gt;Policy Based Management Objects (DMF)&lt;/LI&gt;
&lt;LI&gt;Data Collection (DC)&lt;/LI&gt;
&lt;LI&gt;Server Registration&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;An interesting fact is that the SQL Provider that provides access to these models is almost totally agnostic about these models. It does navigation, and serves these objects to the Powershell host, but without any code that is aware of each of these models. It's made pretty generic and the plan is to start covering all other services (Analysis Server's AMO, RS, etc.) in the same fashion.&lt;/P&gt;
&lt;P&gt;Now, back to 'where are the cmdlet's'.&lt;/P&gt;
&lt;P&gt;We do plan to provider various common cmdlets for common tasks, such as backup, restore, transfer, adding logins and users (pending customer research). But with the provider serving up objects you have almost instant access to any adminstrative commands you need. Let me illustrate this with an example:&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;PS C:\&amp;gt; cd SQLSERVER:\SQL\W2K3-TEST3\KATMAI\Logins&lt;BR&gt;PS SQLSERVER:\SQL\W2K3-TEST3\KATMAI\Logins&amp;gt; $t=get-item TEST&lt;BR&gt;PS SQLSERVER:\SQL\W2K3-TEST3\KATMAI\Logins&amp;gt; $t.ChangePassword("asdasd182eqwke111AA")&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;With tab-completion you will be able to browse the available methods quickly, and&amp;nbsp;changing the&amp;nbsp;password is then a piece of cake.&amp;nbsp; 
&lt;P&gt;Another thing to point out is that if you take a look at SMO, DMF, DC, RS, AMO, and the other object models you will find there are hundreds of different of objects and literally thousands of operations you can perform. Strictly speaking, if you were to provider full coverage you would end up with hundreds (maybe over a thousand)&amp;nbsp;cmdlets. This makes discoverability quite cumbersome (let alone it is a huge investment to unlock something that is inherently available). And the complexity of some of the cmdlets would make it not&amp;nbsp;practical. Take for example the Transact-SQL statement to create a table. This is a very hard thing to encapsulate in a cmdlet (or new-item). Go try to think up the cmdlet to support all of CREATE TABLE. This is where the provider will be your friend. Issue a Get-Item to grab the parent. Instantiate a new SMO object and modify it to your liking. Then parent it with the reference you received from the Provider and create it. This is how this looks like:&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;cd SQLSERVER:\SQL\W2K3-MVP\DEFAULT\Databases\tempdb&lt;BR&gt;$t = new-object Microsoft.SqlServer.Management.Smo.Table&lt;BR&gt;$t.Parent = (get-item .)&lt;BR&gt;$t.Name ="test"&lt;BR&gt;$c = new-object Microsoft.SqlServer.Management.Smo.Column&lt;BR&gt;$c.Parent = $t&lt;BR&gt;$c.Name = "c1"&lt;BR&gt;$c.DataType = ([Microsoft.SqlServer.Management.Smo.DataType]::Int)&lt;BR&gt;$t.Columns.Add($c)&lt;BR&gt;$t.Create()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;This is a simple example. Creating a basic database is even simpler. But if you need more options, it's all there, under your fingertips. And you don't need to wait until we provide a cmdlet for it. But we &lt;U&gt;will&lt;/U&gt; provide cmdlets for everyday tasks. If you have any opinion which cmdlets are important to you, it would be good to hear from you.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8651649" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>Some background on the use of minishells, such as SQLPS</title><link>http://blogs.msdn.com/mwories/archive/2008/06/23/some-background-on-the-use-of-minishells-such-as-sqlps.aspx</link><pubDate>Mon, 23 Jun 2008 19:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8642883</guid><dc:creator>mwories</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwories/comments/8642883.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=8642883</wfw:commentRss><description>&lt;P&gt;Jeffrey Snover posted a very clear article about minishells and SQL Server's use of it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.msdn.com/powershell/archive/2008/06/23/sql-minishells.aspx" mce_href="http://blogs.msdn.com/powershell/archive/2008/06/23/sql-minishells.aspx"&gt;http://blogs.msdn.com/powershell/archive/2008/06/23/sql-minishells.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Jeffrey is Powershell's Architect, well respected in the Powershell community, and it's good to read about his perspective on this.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8642883" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>Evaluating SQL Server Policies through Powershell</title><link>http://blogs.msdn.com/mwories/archive/2008/06/20/evaluating-sql-server-policies-through-powershell.aspx</link><pubDate>Fri, 20 Jun 2008 20:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8625977</guid><dc:creator>mwories</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwories/comments/8625977.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=8625977</wfw:commentRss><description>&lt;P&gt;I found this ping-back on my previous blog post which gives a good overview of one very useful cmdlet that we ship with the Powershell extensions that SQL Server 2008 will deliver. A very helpful article one of the SQL Server MVPs, &lt;A class="" href="http://sqlblog.com/blogs/lara_rubbelke/default.aspx" target=_blank mce_href="http://sqlblog.com/blogs/lara_rubbelke/default.aspx"&gt;Lara Rubbelke&lt;/A&gt;, on the use of &lt;STRONG&gt;Invoke-PolicyEvaluation&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://sqlblog.com/blogs/lara_rubbelke/archive/2008/06/19/evaluating-policies-on-demand-through-powershell.aspx"&gt;&lt;FONT face=Calibri color=#800080 size=3&gt;http://sqlblog.com/blogs/lara_rubbelke/archive/2008/06/19/evaluating-policies-on-demand-through-powershell.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8625977" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>SQL Server Powershell is here!</title><link>http://blogs.msdn.com/mwories/archive/2008/06/14/SQL2008_5F00_Powershell.aspx</link><pubDate>Sun, 15 Jun 2008 01:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8598595</guid><dc:creator>mwories</dc:creator><slash:comments>21</slash:comments><comments>http://blogs.msdn.com/mwories/comments/8598595.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=8598595</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;I am very excited that SQL Server will ship with a pretty solid first release of Powershell extensions with SQL Server 2008. The SQL Server Powershell extensions deliver on a vision that we’ll expand on in the next releases to come. So what’s in this release of SQL Server Powershell?&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;SQLPS&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – a minishell that gives you a complete pre-configured Powershell with all of SQL Server’s extensions preloaded.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;SQL Server Agent integration&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – A new job subsystem for Powershell&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;SQL Server Management Studio Integration&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – context menus on every applicable node in Object Explorer (with connection context reuse. Including SQL security!)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;Four new Providers!&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – new providers for SQL Server relational engine, Registered Servers, Data Collection, and SQL Server Policy Management&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;SQLCMD integration&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – SQLCMD compatible script execution within Powershell (reuses the SQL Server connection context, and even database context of the provider!)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;SQL Server Policy Management&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; &lt;B style="mso-bidi-font-weight: normal"&gt;integration&lt;/B&gt; – Allows evaluation of any Policy&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;Various other cmdlets&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – support the provider, such as conversion of a SMO Urn to a Powershell path, encoding and decoding of SQL identifiers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;SQL Server Powershell redist&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: #1f497d"&gt; – allows you to install SQL Server Powershell with your application or on any machine you need to have it on (this still being built so with the caveat it may be shipped later, or being cut altogether – don’t flame me yet).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As always with every release, a lot of things were left on the cutting floor, such as Powershell editor integration &amp;amp; execution within SSMS (with grid output), Powershell script generation from any SSMS menu, SMO objects generating Powershell script, more cmdlets that address common user scenarios, Analysis Server support. And this doesn’t include a long list of ideas that for the sake of brevity will not discuss here.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The excitement about this release is palpable, and there is no shortness of ideas for the next releases. I think you’ll be pleased with this first release.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;---&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;From recent posts and email I know there is some explanation needed why we ship ‘pre-packaged’ SQLPS functionality. Let me address that here as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;SQLPS is slated to be replacing SQLCMD and other tools that people now use to do ad-hoc management and management task automation. It’s more than that, we want &lt;U&gt;uniformity of management&lt;/U&gt; across ALL of SQL Server services, whether it is Analysis Server, SQL Server, Integration Services, Reporting Services etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;SQLPS.exe is a Minishell (also called “custom shell”). It is a form of pre-packaging of Powershell functionality, and it is available to anyone who wants to do this (make-shell). It &lt;U&gt;is&lt;/U&gt; regular Powershell, albeit with limitations that the Powershell team decided to impose on it – it is a ‘closed’ shell, which doesn’t allow adding other snapins.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;We are shipping SQLPS to make life of our DBA’s a whole lot easier. If they need to have quick access to the SQL providers, assemblies, cmdlets, default security settings, everything is there. We could have possibly done this through a startup script but not everything can be accomplished this way. We are changing the default security settings, without affecting the settings for overall Powershell. Minishells have their own settings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;We also use SQLPS to execute SQL Agent jobs. We pipe the data into SQLPS, as we cannot pass it on the cmdline. From that perspective it serves our purpose very well. This is somewhat harder (if not impossible) to accomplish using the startup script approach.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;That said, in the next release we will look into it to ship a SQPS that is more flexible. Listening to the feedback, we should have a form of packaging that allows users to add cmdlets/providers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;We are however not stopping anyone to create their own startup scripts that include the cmdlets and/or providers for SQL Server, Exchange, IIS etc. etc. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;To get you started on this, here is a script that exactly does that:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;#&lt;BR&gt;# Initialize-SqlpsEnvironment.ps1&lt;BR&gt;#&lt;BR&gt;# Loads the SQL Server provider extensions&lt;BR&gt;#&lt;BR&gt;# Usage: Powershell -NoExit -Command "&amp;amp; '.\Initialize-SqlPsEnvironment.ps1'"&lt;BR&gt;#&lt;BR&gt;# Change log:&lt;BR&gt;# June 14, 2008: Michiel Wories&lt;BR&gt;#&amp;nbsp;&amp;nbsp; Initial Version&lt;BR&gt;# June 17, 2008: Michiel Wories&lt;BR&gt;#&amp;nbsp;&amp;nbsp; Fixed issue with path that did not allow for snapin\provider:: prefix of path&lt;BR&gt;#&amp;nbsp;&amp;nbsp; Fixed issue with provider variables. Provider does not handle case yet&lt;BR&gt;#&amp;nbsp;&amp;nbsp; that these variables do not exist (bug has been filed)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;$ErrorActionPreference = "Stop"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;$sqlpsreg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;if (Get-ChildItem $sqlpsreg -ErrorAction "SilentlyContinue")&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw "SQL Server Powershell is not installed."&lt;BR&gt;}&lt;BR&gt;else&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $item = Get-ItemProperty $sqlpsreg&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sqlpsPath = [System.IO.Path]::GetDirectoryName($item.Path)&lt;BR&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;BR&gt;#&lt;BR&gt;# Preload the assemblies. Note that most assemblies will be loaded when the provider&lt;BR&gt;# is used. if you work only within the provider this may not be needed. It will reduce&lt;BR&gt;# the shell's footprint if you leave these out.&lt;BR&gt;#&lt;BR&gt;$assemblylist = &lt;BR&gt;"Microsoft.SqlServer.Smo",&lt;BR&gt;"Microsoft.SqlServer.Dmf ",&lt;BR&gt;"Microsoft.SqlServer.SqlWmiManagement ",&lt;BR&gt;"Microsoft.SqlServer.ConnectionInfo ",&lt;BR&gt;"Microsoft.SqlServer.SmoExtended ",&lt;BR&gt;"Microsoft.SqlServer.Management.RegisteredServers ",&lt;BR&gt;"Microsoft.SqlServer.Management.Sdk.Sfc ",&lt;BR&gt;"Microsoft.SqlServer.SqlEnum ",&lt;BR&gt;"Microsoft.SqlServer.RegSvrEnum ",&lt;BR&gt;"Microsoft.SqlServer.WmiEnum ",&lt;BR&gt;"Microsoft.SqlServer.ServiceBrokerEnum ",&lt;BR&gt;"Microsoft.SqlServer.ConnectionInfoExtended ",&lt;BR&gt;"Microsoft.SqlServer.Management.Collector ",&lt;BR&gt;"Microsoft.SqlServer.Management.CollectorEnum"&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;BR&gt;foreach ($asm in $assemblylist)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $asm = [Reflection.Assembly]::LoadWithPartialName($asm)&lt;BR&gt;}&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;#&lt;BR&gt;# Set variables that the provider expects (mandatory for the SQL provider)&lt;BR&gt;#&lt;BR&gt;Set-Variable -scope Global -name SqlServerMaximumChildItems -Value 0&lt;BR&gt;Set-Variable -scope Global -name SqlServerConnectionTimeout -Value 30&lt;BR&gt;Set-Variable -scope Global -name SqlServerIncludeSystemObjects -Value $false&lt;BR&gt;Set-Variable -scope Global -name SqlServerMaximumTabCompletion -Value 1000&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;#&lt;BR&gt;# Load the snapins, type data, format data&lt;BR&gt;#&lt;BR&gt;Push-Location&lt;BR&gt;cd $sqlpsPath&lt;BR&gt;Add-PSSnapin SqlServerCmdletSnapin100&lt;BR&gt;Add-PSSnapin SqlServerProviderSnapin100&lt;BR&gt;Update-TypeData -PrependPath SQLProvider.Types.ps1xml &lt;BR&gt;update-FormatData -prependpath SQLProvider.Format.ps1xml &lt;BR&gt;Pop-Location&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Write-Host -ForegroundColor Yellow 'SQL Server Powershell extensions are loaded.'&lt;BR&gt;Write-Host&lt;BR&gt;Write-Host -ForegroundColor Yellow 'Type "cd SQLSERVER:\" to step into the provider.'&lt;BR&gt;Write-Host&lt;BR&gt;Write-Host -ForegroundColor Yellow 'For more information, type "help SQLServer".'&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now, go and use SQL Server Powershell :-). Give us your feedback, and I promise you we’ll listen to it, and we’ll keep on improving on it. This is written for you, the DBA, the IT-PRO, the casual user who needs to do some ad hoc administration or anyone else who uses Powershell for their administrative tasks.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Michiel&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8598595" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>Add oil to fire: SMO and Monad -- a flammable combination</title><link>http://blogs.msdn.com/mwories/archive/2006/01/03/SMO-MSH.aspx</link><pubDate>Tue, 03 Jan 2006 22:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:508874</guid><dc:creator>mwories</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/mwories/comments/508874.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwories/commentrss.aspx?PostID=508874</wfw:commentRss><description>&lt;P&gt;&lt;a href="http://blogs.msdn.com/euanga/"&gt;Euan&lt;/A&gt; pointed me to&amp;nbsp;&lt;A href="http://pluralsight.com/blogs/dan/archive/2005/12/29/17703.aspx"&gt;an interesting article about the use of Monad together with SMO&lt;/A&gt;. Those who know me well, know I am somewhat of a scripting biggot and still install Cygwin on all of my boxes as I cannot live without bash, awk, perk, sed, expr and the various other UNIX tools that I have used over the years. I have been somewhat of a Monad sceptic, but once I saw what the vision behind it was I was quickly turned around. Now history will tell whether MSH is going to be the big hit I expect it to be. But there are several teams here already deeply investing in it and Exchange is a team that already showcases a deep use of Monad and event built their management UI on top of it. SQL Server DBA's have potentially a lot to gain from a good Monad implementation with a set of well implemented cmdlets*.&lt;/P&gt;
&lt;P&gt;I'd love to know what type of cmdlets you'd like to see for SQL Server/SMO, bye the way... This is something we're looking into for the next release.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;*If want to know what a cmdlet is, take a look at &lt;/FONT&gt;&lt;A href="http://download.microsoft.com/download/1/8/f/18f8cee2-0b64-41f2-893d-a6f2295b40c8/TW04038_WINHEC2004.ppt"&gt;&lt;FONT size=2&gt;this deck&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;&amp;nbsp;or this &lt;/FONT&gt;&lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/monad_conc/html/0aa32589-4447-4ead-a5dd-a3be99113140.asp"&gt;&lt;FONT size=2&gt;MSDN article&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=508874" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwories/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/mwories/archive/tags/Powershell/default.aspx">Powershell</category></item></channel></rss>