<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Michiel Wories' WebLog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/mwories/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/mwories/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:19:43 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>An insightful article on a recent Windows Azure service disruption</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/an-insightful-article-on-a-recent-windows-azure-service-disruption</link>
      <pubDate>Thu, 22 Mar 2012 17:17:29 GMT</pubDate>
      <dc:creator><![CDATA[Michiel Wories - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2012/03/22/an-insightful-article-on-a-recent-windows-azure-service-disruption/</guid>
      <description><![CDATA[This was such a great read that I wanted to share it...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;">This was such a great read that I wanted to share it out...</span></p>
<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;"><a href="https://blogs.msdn.com/b/windowsazure/archive/2012/03/10/summary-of-windows-azure-service-disruption-on-feb-29th-2012.aspx">https://blogs.msdn.com/b/windowsazure/archive/2012/03/10/summary-of-windows-azure-service-disruption-on-feb-29th-2012.aspx</a></span></p>
<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;">A factual, actionable, and humble article... Makes me feel proud to work at Microsoft.</span></span></p>
<p><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;">-Michiel</span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>The use of Write-Host and SQL Server Agent PowerShell job steps</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/the-use-of-write-host-and-sql-server-agent-powershell-job-steps</link>
      <pubDate>Wed, 30 Sep 2009 18:42:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2009/09/30/the-use-of-write-host-and-sql-server-agent-powershell-job-steps/</guid>
      <description><![CDATA[SQL Server Agent implements a job subsystem that allows users to directly run PowerShell scripts in...]]></description>
      <content:encoded><![CDATA[<P>SQL Server Agent implements a job subsystem that allows users to directly run PowerShell scripts in SQL Server Agent. Internally this is implemented by reusing the SQLPS.EXE shell stub (which is another shape of POWERSHELL.EXE, but preconfigured for SQL Server).</P>
<P>When SQL Server Agent starts SQLPS.EXE, it does not do this through the console (there is no console attached).</P>
<P>The $Host variable will indicate what host is attached to your runtime. When running SQLPS.EXE on a console this will be your host:</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Courier; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">PS C:\Users\mwories&gt; $Host<BR><BR>Name<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: ConsoleHost<BR>Version<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 2.0<BR>InstanceId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 40b6135d-0f89-4b12-b44e-d3d70a729343<BR>UI<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: System.Management.Automation.Internal.Host.InternalHostUserInterface<BR>CurrentCulture<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>: en-US<BR>CurrentUICulture : en-US<BR>PrivateData<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy<BR>IsRunspacePushed : False<BR>Runspace<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: System.Management.Automation.Runspaces.LocalRunspace<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal>However print the host variable in an Agent Job and you will see this:</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Courier; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt">Name<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: Default Host<BR>Version<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 2.0<BR>InstanceId<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: 9cf1e259-93b1-476f-8c3f-6fe9cf935aab<BR>UI<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: System.Management.Automation.Internal.Host.InternalHostUserInterface<BR>CurrentCulture<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>: en-US<BR>CurrentUICulture : en-US<BR>PrivateData<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: <BR>IsRunspacePushed : <BR>Runspace<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>:<o:p></o:p></SPAN></P>
<P>The article <A title="How PowerShell Works" href="https://msdn.microsoft.com/en-us/library/ms714658(VS.85).aspx" target=_blank mce_href="https://msdn.microsoft.com/en-us/library/ms714658(VS.85).aspx">How PowerShell Works</A> explains well how the runspace interacts with the host.</P>
<P>The Host implement PSHostUserInterface and PSHostRawUserInterface that form the display interface. These may not implement certain methods for the Default Host. And indeed, for the Default Host (the host an Agent Job receives, as there is no console), the method that implements Write-Host is not available, and it will fail with the following message:</P>
<P>Executed as user: REDMOND\mwories. A job step received an error at line 3 in a PowerShell script. The corresponding line is 'write-host 'foobar''. Correct the script and reschedule the job. The error information returned by PowerShell is: '<STRONG>Cannot invoke this function because the current host does not implement it</STRONG>.&nbsp; '.&nbsp; Process Exit Code -1.&nbsp; The step failed.</P>
<P>Now what to do when you want to create your scripts to run in a console but also hosts that may not have a console, and may not implement any host output interface?</P>
<P>This will work.</P>
<P>if ($host.Name -eq "ConsoleHost")<BR>{<BR>&nbsp;write-host 'foobar'<BR>}</P>
<P>Of course you can find ways to simplify your scripts by wrapping this in a function that only writes output when a console is attached.</P>
<P>If there is any output that you like to be logged, it will not appear in the SQL Agent output. It is therefore better to use Write-Output if you want to provide some kind of output that shows up in SQL Agent output or history.</P>
<P>Hope this helps to understand the PowerShell subsystem in SQL Server Agent a bit better.</P>]]></content:encoded>
    </item>
    <item>
      <title>PowerShell Tips &amp; Tricks: Getting more detailed error information from PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/powershell-tips-tricks-getting-more-detailed-error-information-from-powershell</link>
      <pubDate>Mon, 08 Jun 2009 11:41:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2009/06/08/powershell-tips-tricks-getting-more-detailed-error-information-from-powershell/</guid>
      <description><![CDATA[Allen White wrote this handy blogpost on how to handle error message and get more information out of...]]></description>
      <content:encoded><![CDATA[<P>Allen White wrote this handy blogpost on how to handle error message and get more information out of an error record:</P>
<P><A href="https://sqlblog.com/blogs/allen_white/archive/2009/06/08/handling-errors-in-powershell.aspx" mce_href="https://sqlblog.com/blogs/allen_white/archive/2009/06/08/handling-errors-in-powershell.aspx">https://sqlblog.com/blogs/allen_white/archive/2009/06/08/handling-errors-in-powershell.aspx</A></P>
<P>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...</P>
<P>An example; let's generate a simple error (recreate master will not work on most systems):</P>
<BLOCKQUOTE>
<P><STRONG>$db = new Microsoft.SqlServer.Management.Smo.Database<BR>$db.Name = "master"<BR>$db.Parent = get-item .<BR>$db.Create()<BR>Exception calling "Create" with "0" argument(s): "Create failed for Database 'master'. "<BR>At line:1 char:11<BR>+ $db.Create( &lt;&lt;&lt;&lt; )<BR></STRONG></P></BLOCKQUOTE>
<P>Not very helpful is it?</P>
<P>Here is where this little gem comes in:</P>
<BLOCKQUOTE>
<P><STRONG>$error[0]|format-list -force</STRONG></P></BLOCKQUOTE>
<P>Now let's take a look at the details this emits:</P>
<P mce_keep="true"><STRONG>Exception&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: System.Management.Automation.MethodInvocationException:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exception calling "Create" with "0" argument(s): "Crea<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; te failed for Database 'master'. " ---&gt; Microsoft.SqlSe<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rver.Management.Smo.FailedOperationException: Create fa<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iled for Database 'master'.&nbsp; ---&gt; Microsoft.SqlServer.M<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anagement.Common.ExecutionFailureException: An exceptio<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n occurred while executing a Transact-SQL statement or <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; batch. ---&gt; System.Data.SqlClient.SqlException: Databas<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e 'master' already exists. Choose a different database <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Data.SqlClient.SqlConnection.OnError(SqlEx<BR><EM>&lt;cutting middle part out&gt;<BR></EM>TargetObject&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <BR>CategoryInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : NotSpecified: (:) [], MethodInvocationException<BR>FullyQualifiedErrorId : DotNetMethodTargetInvocation<BR>ErrorDetails&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <BR>InvocationInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : System.Management.Automation.InvocationInfo</STRONG></P>
<P mce_keep="true"><BR>Well, now THAT's more like it!</P>
<P mce_keep="true">As you can see the -force flag does a couple of nice things.</P>
<OL>
<LI>
<DIV mce_keep="true">It concatenates the error messages into a somewhat understandable result.</DIV></LI>
<LI>
<DIV mce_keep="true">It dumps stack information + all other error information avalable.</DIV></LI></OL>
<P mce_keep="true">Generally it's a time saver as you have this command readily available for you at the command line.</P>
<P mce_keep="true">Do you have any tips on error handling? I'd love to hear about it.</P>
<P mce_keep="true">-Michiel</P>]]></content:encoded>
    </item>
    <item>
      <title>Talking about SQLPS (SQL Server Powershell extensions) on Runas Radio</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/talking-about-sqlps-sql-server-powershell-extensions-on-runas-radio</link>
      <pubDate>Wed, 24 Sep 2008 13:42:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2008/09/24/talking-about-sqlps-sql-server-powershell-extensions-on-runas-radio/</guid>
      <description><![CDATA[I was recently interviewed on RunAs Radio on the new Powershell extensions that we developed for SQL...]]></description>
      <content:encoded><![CDATA[<P>I was recently interviewed on RunAs Radio on the new Powershell extensions that we developed for SQL Server 2008.</P>
<P>If you want to learn more about SQL Server Powershell download the podcast here : <A href="https://www.runasradio.com/default.aspx?showNum=75">https://www.runasradio.com/default.aspx?showNum=75</A></P>
<P>If you listened to it then please post your feedback here.</P>
<P>Happy listening!</P>]]></content:encoded>
    </item>
    <item>
      <title>What? No cmdlets? -- SQL Server Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/what-no-cmdlets-sql-server-powershell</link>
      <pubDate>Wed, 25 Jun 2008 03:25:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2008/06/25/what-no-cmdlets-sql-server-powershell/</guid>
      <description><![CDATA[When you start using the SQL Server Powershell extensions, you will find there are not a whole lot...]]></description>
      <content:encoded><![CDATA[<P>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 <U>do</U> 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.</P>
<P>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).</P>
<P>Right now you will find that you can navigate to four different object models:</P>
<UL>
<LI>SQL Server Relational Managenent Objects (SMO)</LI>
<LI>Policy Based Management Objects (DMF)</LI>
<LI>Data Collection (DC)</LI>
<LI>Server Registration</LI></UL>
<P>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.</P>
<P>Now, back to 'where are the cmdlet's'.</P>
<P>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:</P><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
<P><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt">PS C:\&gt; cd SQLSERVER:\SQL\W2K3-TEST3\KATMAI\Logins<BR>PS SQLSERVER:\SQL\W2K3-TEST3\KATMAI\Logins&gt; $t=get-item TEST<BR>PS SQLSERVER:\SQL\W2K3-TEST3\KATMAI\Logins&gt; $t.ChangePassword("asdasd182eqwke111AA")<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P></SPAN>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><o:p><FONT size=3></FONT></o:p></SPAN></P>With tab-completion you will be able to browse the available methods quickly, and&nbsp;changing the&nbsp;password is then a piece of cake.&nbsp; 
<P>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)&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&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:</P><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
<P><SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt">cd SQLSERVER:\SQL\W2K3-MVP\DEFAULT\Databases\tempdb<BR>$t = new-object Microsoft.SqlServer.Management.Smo.Table<BR>$t.Parent = (get-item .)<BR>$t.Name ="test"<BR>$c = new-object Microsoft.SqlServer.Management.Smo.Column<BR>$c.Parent = $t<BR>$c.Name = "c1"<BR>$c.DataType = ([Microsoft.SqlServer.Management.Smo.DataType]::Int)<BR>$t.Columns.Add($c)<BR>$t.Create()<o:p></o:p></SPAN></P>
<P></SPAN>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 <U>will</U> provide cmdlets for everyday tasks. If you have any opinion which cmdlets are important to you, it would be good to hear from you.</P>]]></content:encoded>
    </item>
    <item>
      <title>Some background on the use of minishells, such as SQLPS</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/some-background-on-the-use-of-minishells-such-as-sqlps</link>
      <pubDate>Mon, 23 Jun 2008 12:58:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2008/06/23/some-background-on-the-use-of-minishells-such-as-sqlps/</guid>
      <description><![CDATA[Jeffrey Snover posted a very clear article about minishells and SQL Server's use of...]]></description>
      <content:encoded><![CDATA[<P>Jeffrey Snover posted a very clear article about minishells and SQL Server's use of it:</P>
<P>&nbsp;<A href="https://blogs.msdn.com/powershell/archive/2008/06/23/sql-minishells.aspx" mce_href="https://blogs.msdn.com/powershell/archive/2008/06/23/sql-minishells.aspx">https://blogs.msdn.com/powershell/archive/2008/06/23/sql-minishells.aspx</A></P>
<P>&nbsp;Jeffrey is Powershell's Architect, well respected in the Powershell community, and it's good to read about his perspective on this.</P>]]></content:encoded>
    </item>
    <item>
      <title>Evaluating SQL Server Policies through Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/evaluating-sql-server-policies-through-powershell</link>
      <pubDate>Fri, 20 Jun 2008 13:27:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2008/06/20/evaluating-sql-server-policies-through-powershell/</guid>
      <description><![CDATA[I found this ping-back on my previous blog post which gives a good overview of one very useful...]]></description>
      <content:encoded><![CDATA[<P>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, <A class="" href="https://sqlblog.com/blogs/lara_rubbelke/default.aspx" target=_blank mce_href="https://sqlblog.com/blogs/lara_rubbelke/default.aspx">Lara Rubbelke</A>, on the use of <STRONG>Invoke-PolicyEvaluation</STRONG>:</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><A href="https://sqlblog.com/blogs/lara_rubbelke/archive/2008/06/19/evaluating-policies-on-demand-through-powershell.aspx"><FONT face=Calibri color=#800080 size=3>https://sqlblog.com/blogs/lara_rubbelke/archive/2008/06/19/evaluating-policies-on-demand-through-powershell.aspx</FONT></A></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt" mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Powershell is here!</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/sql-server-powershell-is-here</link>
      <pubDate>Sat, 14 Jun 2008 18:35:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2008/06/14/sql-server-powershell-is-here/</guid>
      <description><![CDATA[I am very excited that SQL Server will ship with a pretty solid first release of Powershell...]]></description>
      <content:encoded><![CDATA[<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">SQLPS</SPAN></B><SPAN style="COLOR: #1f497d"> – a minishell that gives you a complete pre-configured Powershell with all of SQL Server’s extensions preloaded.<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">SQL Server Agent integration</SPAN></B><SPAN style="COLOR: #1f497d"> – A new job subsystem for Powershell<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">SQL Server Management Studio Integration</SPAN></B><SPAN style="COLOR: #1f497d"> – context menus on every applicable node in Object Explorer (with connection context reuse. Including SQL security!)<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">Four new Providers!</SPAN></B><SPAN style="COLOR: #1f497d"> – new providers for SQL Server relational engine, Registered Servers, Data Collection, and SQL Server Policy Management<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">SQLCMD integration</SPAN></B><SPAN style="COLOR: #1f497d"> – SQLCMD compatible script execution within Powershell (reuses the SQL Server connection context, and even database context of the provider!)<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">SQL Server Policy Management</SPAN></B><SPAN style="COLOR: #1f497d"> <B style="mso-bidi-font-weight: normal">integration</B> – Allows evaluation of any Policy<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">Various other cmdlets</SPAN></B><SPAN style="COLOR: #1f497d"> – support the provider, such as conversion of a SMO Urn to a Powershell path, encoding and decoding of SQL identifiers.<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="COLOR: #1f497d; mso-fareast-font-family: Calibri; mso-bidi-font-family: Calibri"><SPAN style="mso-list: Ignore"><FONT face=Calibri size=3>-</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=3><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><SPAN style="COLOR: #1f497d">SQL Server Powershell redist</SPAN></B><SPAN style="COLOR: #1f497d"> – 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).<o:p></o:p></SPAN></FONT></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>As always with every release, a lot of things were left on the cutting floor, such as Powershell editor integration &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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>---<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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 <U>uniformity of management</U> across ALL of SQL Server services, whether it is Analysis Server, SQL Server, Integration Services, Reporting Services etc.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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 <U>is</U> 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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>To get you started on this, here is a script that exactly does that:<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt">#<BR># Initialize-SqlpsEnvironment.ps1<BR>#<BR># Loads the SQL Server provider extensions<BR>#<BR># Usage: Powershell -NoExit -Command "&amp; '.\Initialize-SqlPsEnvironment.ps1'"<BR>#<BR># Change log:<BR># June 14, 2008: Michiel Wories<BR>#&nbsp;&nbsp; Initial Version<BR># June 17, 2008: Michiel Wories<BR>#&nbsp;&nbsp; Fixed issue with path that did not allow for snapin\provider:: prefix of path<BR>#&nbsp;&nbsp; Fixed issue with provider variables. Provider does not handle case yet<BR>#&nbsp;&nbsp; that these variables do not exist (bug has been filed)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt">$ErrorActionPreference = "Stop"</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt">$sqlpsreg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps"</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt">if (Get-ChildItem $sqlpsreg -ErrorAction "SilentlyContinue")<BR>{<BR>&nbsp;&nbsp;&nbsp; throw "SQL Server Powershell is not installed."<BR>}<BR>else<BR>{<BR>&nbsp;&nbsp;&nbsp; $item = Get-ItemProperty $sqlpsreg<BR>&nbsp;&nbsp;&nbsp; $sqlpsPath = [System.IO.Path]::GetDirectoryName($item.Path)<BR>}</SPAN></P><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt">
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><BR>#<BR># Preload the assemblies. Note that most assemblies will be loaded when the provider<BR># is used. if you work only within the provider this may not be needed. It will reduce<BR># the shell's footprint if you leave these out.<BR>#<BR>$assemblylist = <BR>"Microsoft.SqlServer.Smo",<BR>"Microsoft.SqlServer.Dmf ",<BR>"Microsoft.SqlServer.SqlWmiManagement ",<BR>"Microsoft.SqlServer.ConnectionInfo ",<BR>"Microsoft.SqlServer.SmoExtended ",<BR>"Microsoft.SqlServer.Management.RegisteredServers ",<BR>"Microsoft.SqlServer.Management.Sdk.Sfc ",<BR>"Microsoft.SqlServer.SqlEnum ",<BR>"Microsoft.SqlServer.RegSvrEnum ",<BR>"Microsoft.SqlServer.WmiEnum ",<BR>"Microsoft.SqlServer.ServiceBrokerEnum ",<BR>"Microsoft.SqlServer.ConnectionInfoExtended ",<BR>"Microsoft.SqlServer.Management.Collector ",<BR>"Microsoft.SqlServer.Management.CollectorEnum"</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><BR>foreach ($asm in $assemblylist)<BR>{<BR>&nbsp;&nbsp;&nbsp; $asm = [Reflection.Assembly]::LoadWithPartialName($asm)<BR>}</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">#<BR># Set variables that the provider expects (mandatory for the SQL provider)<BR>#<BR>Set-Variable -scope Global -name SqlServerMaximumChildItems -Value 0<BR>Set-Variable -scope Global -name SqlServerConnectionTimeout -Value 30<BR>Set-Variable -scope Global -name SqlServerIncludeSystemObjects -Value $false<BR>Set-Variable -scope Global -name SqlServerMaximumTabCompletion -Value 1000</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">#<BR># Load the snapins, type data, format data<BR>#<BR>Push-Location<BR>cd $sqlpsPath<BR>Add-PSSnapin SqlServerCmdletSnapin100<BR>Add-PSSnapin SqlServerProviderSnapin100<BR>Update-TypeData -PrependPath SQLProvider.Types.ps1xml <BR>update-FormatData -prependpath SQLProvider.Format.ps1xml <BR>Pop-Location</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Write-Host -ForegroundColor Yellow 'SQL Server Powershell extensions are loaded.'<BR>Write-Host<BR>Write-Host -ForegroundColor Yellow 'Type "cd SQLSERVER:\" to step into the provider.'<BR>Write-Host<BR>Write-Host -ForegroundColor Yellow 'For more information, type "help SQLServer".'<BR></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 9pt; COLOR: #1f497d; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 11.0pt"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>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.<o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><o:p><FONT face=Calibri size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="COLOR: #1f497d"><FONT size=3><FONT face=Calibri>Michiel<o:p></o:p></FONT></FONT></SPAN></P>]]></content:encoded>
    </item>
    <item>
      <title>How to change the SQL Server password programmatically</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/how-to-change-the-sql-server-password-programmatically</link>
      <pubDate>Fri, 03 Nov 2006 19:32:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2006/11/03/how-to-change-the-sql-server-password-programmatically/</guid>
      <description><![CDATA[Every now and the question comes up how to programmatically modify the service account or password...]]></description>
      <content:encoded><![CDATA[<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>Every now and the question comes up how to programmatically modify the service account or password of SQL Server. There basically two ways to accomplish this, using SMO, or WMI. This article shows you how to use WMI and VBScript to accomplish this task.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>There are a couple of things you need to know.</FONT></P>
<UL style="MARGIN-TOP: 0in" type=disc>
<LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=3>SQL Server <U>does not need a reboot</U> when the password is modified. We (SQL Server Team) spent quite a bit of time ensuring you do not suffer any unnecessary downtime when performing an operation that has to happen regularly, when password are expiring. Everyone likes a ‘no reboot’ clause, right?</FONT></LI>
<LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=3>When changing the account and password, the service does need a reboot, but the WMI Provider does this for you. In fact, if the service is not started it will be brought up for a short moment. If it already running it will be restarted. The reasons are as follows:</FONT></LI>
<UL style="MARGIN-TOP: 0in" type=circle>
<LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"><FONT face="Times New Roman" size=3>The service master key needs to be re-encrypted</FONT></LI>
<LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"><FONT face="Times New Roman" size=3>Various other security settings are done</FONT></LI></UL>
<LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=3>Because the WMI Provider performs various operations besides changing the service account, other account change methods like ‘sc’ or the standard service control panel are not supported. You may see that the service will not start in some cases.</FONT></LI>
<LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=3>Changing the password only tells the service that the password has changed. If you want to change the account’s password, use a command like NET USER. You need to run that first.</FONT></LI></UL>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>The following scripts allow you to change the service account + password, or only the password:</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face="Times New Roman">setaccount.vbs:<o:p></o:p></FONT></FONT></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt">‘ Set the account and password<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt">set svr = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement:SqlService.ServiceName='MSSQL$<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:State w:st="on"><st1:place w:st="on">YUKON</st1:place></st1:State>',SQLServiceType=1")<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt">svr.SetServiceAccount ".\TestUser", "NewPassword!!"<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face="Times New Roman">setpwd.vbs:<o:p></o:p></FONT></FONT></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt">‘ Set the password<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt">set svr = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement:SqlService.ServiceName='MSSQL$<st1:place w:st="on"><st1:State w:st="on">YUKON</st1:State></st1:place>',SQLServiceType=1")<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt">svr.SetServiceAccountPassword "", "NewPassword2!!"<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN style="mso-spacerun: yes"></SPAN>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>You need to change 'MSSQL$<st1:State w:st="on">YUKON</st1:State>' to match your instance name (replace ‘<st1:State w:st="on"><st1:place w:st="on">YUKON</st1:place></st1:State>’ with the instance name, or the entire string with MSSQLSERVER for the default instance). Of course the account and password need to be changed as well.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>Try this on a test server first before running this on a production server.</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>I hope this is helpful,</FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>Michiel</FONT></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>SMO Sample: Enable TCP/IP Server protocol of SQL Server 2005</title>
      <link>https://docs.microsoft.com/archive/blogs/mwories/smo-sample-enable-tcpip-server-protocol-of-sql-server-2005</link>
      <pubDate>Fri, 10 Feb 2006 20:09:00 GMT</pubDate>
      <dc:creator><![CDATA[mwories]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwories/2006/02/10/smo-sample-enable-tcpip-server-protocol-of-sql-server-2005/</guid>
      <description><![CDATA[Purpose of sample: Enable the TCP/IP server protocol.
&nbsp;
This sample shows you how to change a...]]></description>
      <content:encoded><![CDATA[<DIV>Purpose of sample: Enable the TCP/IP server protocol.</DIV>
<DIV>&nbsp;</DIV>
<DIV>This sample shows you how to change a server protocol setting. This sample assumes you have SQL Express installed. You need to change the instance name to match the instance name you have installed.</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>
<P></FONT><FONT color=#008080 size=2>ManagedComputer</FONT><FONT size=2> mc = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>ManagedComputer</FONT><FONT size=2>();</P>
<P>mc.ServerInstances[</FONT><FONT color=#800000 size=2>"SQLEXPRESS"</FONT><FONT size=2>].ServerProtocols[</FONT><FONT color=#800000 size=2>"Tcp"</FONT><FONT size=2>].IsEnabled = </FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2>;</P></FONT></DIV>]]></content:encoded>
    </item>
  </channel>
</rss>