<?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>Mike Wilbur's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/mwilbur/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/mwilbur/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:24:44 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Renaming a network connection with netsh</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/renaming-a-network-connection-with-netsh</link>
      <pubDate>Wed, 01 Aug 2007 16:14:00 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/08/01/renaming-a-network-connection-with-netsh/</guid>
      <description><![CDATA[Example:

netsh interface set interface name="Local Area Connection" newname="ExampleLan"]]></description>
      <content:encoded><![CDATA[<P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri">Example:</P>
<BLOCKQUOTE>
<P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri">netsh interface set interface name="Local Area Connection" newname="ExampleLan"</P></BLOCKQUOTE>]]></content:encoded>
    </item>
    <item>
      <title>Powershell Template Engine</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/powershell-template-engine</link>
      <pubDate>Thu, 15 Mar 2007 01:37:10 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/03/15/powershell-template-engine/</guid>
      <description><![CDATA[A template engine that allows you to have powershell expressions in your templates is a very...]]></description>
      <content:encoded><![CDATA[<p>A template engine that allows you to have powershell expressions in your templates is a very powerful thing: <a title="https://weblogs.asp.net/soever/archive/2006/12/31/a-templating-engine-using-powershell-expressions.aspx" href="https://weblogs.asp.net/soever/archive/2006/12/31/a-templating-engine-using-powershell-expressions.aspx">https://weblogs.asp.net/soever/archive/2006/12/31/a-templating-engine-using-powershell-expressions.aspx</a></p> <p><strong>Example Input:</strong></p> <blockquote> <p></p> <p>Multi Line Expression:<br>[[ get-date<br>1..20<br>]] <p>Define function [[ function get-theanswer {42;} ]]  <p>Single Line: [[ theanswer ]]  <p>EOF</p></blockquote> <p><strong>Example Output:</strong>  <blockquote> <p>Multi Line Expression:<br>03/14/2007 22:38:09 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <p>Define function  <p>Single Line: 42  <p>EOF</p></blockquote> <p>The implementation uses dynamic code generation to build an assembly in order to have a delegate to pass to&nbsp;regex.replace.&nbsp;  <p>Using code generation felt a bit over complicated, and I wondered if it could be simpler. <p>Some thinking and tinkering later, I arrived at a working implementation.  <p>Getting the multiline regex expression working correctly caused me some difficulty; as it only seems to correctly handle \R as a line separator.  <p>I also added the ability to pipe text to the script, since I like to use the syntax: gc file.txt | expand-template <p>Now as with any powerful tool you'll need to be careful, and be sure that you fully trust the template file (other wise you'll be vulnerable to a code injection attack) <p><strong>Expand-Template.ps1:</strong> </p><pre class="code" style="overflow: auto">param (<span style="color: #35687d">$text</span>=<span style="color: maroon">""</span>,<span style="color: #35687d">$BeginTag</span>=<span style="color: maroon">'[['</span>,<span style="color: #35687d">$EndTag</span>=<span style="color: maroon">']]'</span>) 
<span style="color: #35687d">$begintag</span> = [regex]::escape(<span style="color: #35687d">$begintag</span>) 
<span style="color: #35687d">$endtag</span> = [regex]::escape(<span style="color: #35687d">$endtag</span>) 
<span style="color: #35687d">$output</span>=<span style="color: maroon">""</span> 

<span style="color: #35687d">$input</span> | %{<span style="color: #35687d">$text</span>+=[string]<span style="color: #35687d">$_</span> + <span style="color: maroon">"`r"</span>} 

<span style="color: blue">while</span> (<span style="color: #35687d">$text</span> -match <span style="color: maroon">"(?m)(?&lt;pre&gt;.*?)$begintag(?&lt;exp&gt;.*?)$endtag(?&lt;post&gt;.*)"</span>) { 
  <span style="color: #35687d">$text</span> = <span style="color: #35687d">$matches</span>.post 
  <span style="color: #35687d">$output</span> += <span style="color: #35687d">$matches</span>.pre 
  <span style="color: #35687d">$output</span> += <span style="color: #2b91af">invoke-expression</span> <span style="color: #35687d">$matches</span>.exp 
} 

<span style="color: #35687d">$output</span> += <span style="color: #35687d">$text</span> 
<span style="color: #35687d">$output</span> -replace <span style="color: maroon">"`r"</span>, [environment]::newline 
</pre>]]></content:encoded>
    </item>
    <item>
      <title>get-SHA256</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/get-sha256</link>
      <pubDate>Wed, 14 Mar 2007 23:10:49 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/03/14/get-sha256/</guid>
      <description><![CDATA[Get the SHA256 hash in one line of powershell: function get-sha256...]]></description>
      <content:encoded><![CDATA[<p>Get the SHA256 hash in one line of powershell:</p> <p>function get-sha256 {<br>param($file);[system.bitconverter]::tostring([System.Security.Cryptography.sha256]::create().computehash([system.io.file]::openread((resolve-path $file)))) -replace "-",""<br>}</p>]]></content:encoded>
    </item>
    <item>
      <title>get-datatable.ps1</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/get-datatable-ps1</link>
      <pubDate>Sat, 10 Mar 2007 15:40:57 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/03/10/get-datatable-ps1/</guid>
      <description><![CDATA[get-datatable.ps1 is an improvement on the get-dataset.ps1 from an earlier post. Instead of...]]></description>
      <content:encoded><![CDATA[<p>get-datatable.ps1 is an improvement on the get-dataset.ps1 from an <a href="https://blogs.msdn.com/mwilbur/archive/2007/02/25/updating-a-dataset-with-powershell-and-saving-changes-back-to-sql.aspx">earlier post</a>. Instead of returning a dataset it returns a DataTable; and a UpdateSql method is added to the object returned, so you don't need a separate script to send the changes back to sql.</p> <p>This allows updates to a small table&nbsp;to look like:</p> <blockquote> <p>$t = datatable "select * from stuff" -db foo<br>$t | %{ .... update the data rows ...&nbsp;}<br>$t.UpdateSql()</p></blockquote> <p>Get-DataTable.ps1:</p> <div class="code" style="overflow: auto"><pre>param (<span style="color: #35687d">$sql</span>,<span style="color: #35687d">$server</span>=<span style="color: maroon">"."</span>,<span style="color: #35687d">$db</span>) 

<span style="color: #35687d">$connectionstring</span>= <span style="color: maroon">"Server=$server;database=$db;trusted_connection=yes;"</span> 
<span style="color: #35687d">$dt</span> = <span style="color: #2b91af">new-object</span> data.DataTable 
<span style="color: #35687d">$da</span> = <span style="color: #2b91af">New-Object</span> system.data.sqlclient.sqldataadapter <span style="color: #35687d">$sql</span>, <span style="color: #35687d">$connectionstring</span> 
<span style="color: #35687d">$null</span> = <span style="color: #35687d">$da</span>.Fill(<span style="color: #35687d">$dt</span>) 
<span style="color: #35687d">$dt</span>.ExtendedProperties[<span style="color: maroon">"sql"</span>]= <span style="color: #35687d">$sql</span> 
<span style="color: #35687d">$dt</span>.ExtendedProperties[<span style="color: maroon">"connectionstring"</span>]= <span style="color: #35687d">$connectionstring</span> 

<span style="color: #35687d">$dt</span> = <span style="color: #2b91af">add-member</span> ScriptMethod UpdateSql { 
<span style="color: #35687d">$da</span> = <span style="color: #2b91af">New-Object</span> system.data.sqlclient.sqldataadapter <span style="color: #35687d">$this</span>.ExtendedProperties[<span style="color: maroon">"sql"</span>], <span style="color: #35687d">$this</span>.ExtendedProperties[<span style="color: maroon">"connectionstring"</span>] 

<span style="color: #35687d">$cb</span> = <span style="color: #2b91af">new-object</span> system.data.sqlclient.sqlcommandbuilder <span style="color: #35687d">$da</span> 
<span style="color: #35687d">$da</span>.UpdateCommand = <span style="color: #35687d">$cb</span>.GetUpdateCommand() 
<span style="color: #35687d">$da</span>.InsertCommand = <span style="color: #35687d">$cb</span>.GetInsertCommand() 
<span style="color: #35687d">$da</span>.DeleteCommand = <span style="color: #35687d">$cb</span>.GetDeleteCommand() 
<span style="color: #35687d">$null</span> = <span style="color: #35687d">$da</span>.Update(<span style="color: #35687d">$this</span>) 
} -<span style="color: blue">in</span> <span style="color: #35687d">$dt</span> -pass 

<span style="color: green">#return data table in array so table doesn't get decomposed into an array of data rows.</span> 
,<span style="color: #35687d">$dt</span></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>Managing Performance Counters via Command Line</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/managing-performance-counters-via-command-line</link>
      <pubDate>Fri, 09 Mar 2007 00:56:51 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/03/09/managing-performance-counters-via-command-line/</guid>
      <description><![CDATA[When it comes to scripting the setup of performance counters Logman is your friend; and Relog comes...]]></description>
      <content:encoded><![CDATA[<p>When it comes to scripting the setup of performance counters <a href="https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_logman.mspx?mfr=true">Logman</a> is your friend; and <a href="https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_logman.mspx?mfr=true">Relog</a> comes in really handy for converting a binary log to SQL log.</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Automated Installation Kit (AIK)</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/windows-automated-installation-kit-aik</link>
      <pubDate>Wed, 28 Feb 2007 00:28:57 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/02/28/windows-automated-installation-kit-aik/</guid>
      <description><![CDATA[It's great to see powerful tools be made&nbsp;publicly available; winpe and imagex are powerful...]]></description>
      <content:encoded><![CDATA[<p>It's great to see powerful tools be made&nbsp;publicly available; <a href="https://en.wikipedia.org/wiki/Winpe">winpe</a> and <a href="https://technet.microsoft.com/en-us/windowsvista/aa905070.aspx">imagex</a> are powerful tools I've been using for some time to deploy systems and recover from hardware &amp; software failures.</p><a href="https://www.microsoft.com/downloads/details.aspx?FamilyID=c7d4bc6d-15f3-4284-9123-679830d629f2&amp;DisplayLang=en">Windows Automated Installation Kit (AIK)</a>  <blockquote> <p><strong>Overview</strong></p> <p><a></a>The Windows Automated Installation Kit (Windows AIK) is designed to help corporate IT professionals customize and deploy the Microsoft Windows Vista™ family of operation systems. By using Windows AIK, you can perform unattended Windows installations, capture Windows images with ImageX, and create Windows PE images.</p></blockquote>]]></content:encoded>
    </item>
    <item>
      <title>Updating a DataSet with Powershell and saving changes back to SQL</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/updating-a-dataset-with-powershell-and-saving-changes-back-to-sql</link>
      <pubDate>Mon, 26 Feb 2007 00:35:00 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/02/26/updating-a-dataset-with-powershell-and-saving-changes-back-to-sql/</guid>
      <description><![CDATA[This example uses the AdventureWorks sample database.
# get the dataset 
PS C:\demo&gt; $ds =...]]></description>
      <content:encoded><![CDATA[<P>This example uses the <A href="https://www.microsoft.com/downloads/details.aspx?FamilyID=e719ecf7-9f46-4312-af89-6ad8702e4e6e&amp;DisplayLang=en" mce_href="https://www.microsoft.com/downloads/details.aspx?FamilyID=e719ecf7-9f46-4312-af89-6ad8702e4e6e&amp;DisplayLang=en">AdventureWorks sample</A> database.</P>
<DIV class=code style="OVERFLOW: auto"><PRE><SPAN style="COLOR: green"># get the dataset</SPAN> 
<SPAN style="COLOR: #2b91af">PS</SPAN> C:\demo&gt; <SPAN style="COLOR: #35687d">$ds</SPAN> = .\get-dataset.ps1 <SPAN style="COLOR: maroon">"select * from Production.ProductModel"</SPAN> -db adventureworks 
<SPAN style="COLOR: green"># write out xml from the instructions column into seperate files</SPAN> 
<SPAN style="COLOR: #2b91af">PS</SPAN> C:\demo&gt; <SPAN style="COLOR: #35687d">$ds</SPAN>.Tables[<SPAN style="COLOR: maroon">0</SPAN>] | ?{<SPAN style="COLOR: #35687d">$_</SPAN>[<SPAN style="COLOR: maroon">"instructions"</SPAN>] -ne [dbnull]::value } | %{<SPAN style="COLOR: #35687d">$_</SPAN>[<SPAN style="COLOR: maroon">"instructions"</SPAN>]| <SPAN style="COLOR: #2b91af">sc</SPAN> <SPAN style="COLOR: maroon">"productmodel-$($_['productmodelid']).xml"</SPAN>} 
<SPAN style="COLOR: green"># verify output</SPAN> 
<SPAN style="COLOR: #2b91af">PS</SPAN> C:\demo&gt; <SPAN style="COLOR: #2b91af">ls</SPAN> productmodel-* 

    Directory: Microsoft.PowerShell.Core\FileSystem::C:\demo

Mode                LastWriteTime     Length Name   
----                -------------     ------ ----                                                                  
-a---         2/25/2007   8:47 PM       5567 productmodel-10.xml
-a---         2/25/2007   8:47 PM       2142 productmodel-43.xml
-a---         2/25/2007   8:47 PM       1967 productmodel-44.xml
-a---         2/25/2007   8:47 PM       4051 productmodel-47.xml
-a---         2/25/2007   8:47 PM       4078 productmodel-48.xml
-a---         2/25/2007   8:47 PM       1927 productmodel-53.xml
-a---         2/25/2007   8:47 PM       1565 productmodel-66.xml
-a---         2/25/2007   8:47 PM       1572 productmodel-67.xml
-a---         2/25/2007   8:47 PM       5340 productmodel-7.xml

<SPAN style="COLOR: green"># now lets make some xml files for product model 1-5</SPAN> 
<SPAN style="COLOR: #2b91af">PS</SPAN> C:\demo&gt; <SPAN style="COLOR: maroon">1</SPAN>.<SPAN style="COLOR: maroon">.5</SPAN> | %{<SPAN style="COLOR: #2b91af">cp</SPAN> productmodel-<SPAN style="COLOR: maroon">10</SPAN>.xml productmodel-<SPAN style="COLOR: #35687d">$_</SPAN>.xml} 
<SPAN style="COLOR: green"># Update the dataset with the new xml content from the files</SPAN> 
<SPAN style="COLOR: #2b91af">PS</SPAN> C:\demo&gt; <SPAN style="COLOR: #35687d">$ds</SPAN>.Tables[<SPAN style="COLOR: maroon">0</SPAN>] | %{<SPAN style="COLOR: #35687d">$file</SPAN> = <SPAN style="COLOR: maroon">"productmodel-$($_['productmodelid']).xml"</SPAN>;<SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: #2b91af">test-path</SPAN> <SPAN style="COLOR: #35687d">$file</SPAN>) {<SPAN style="COLOR: #35687d">$_</SPAN>[<SPAN style="COLOR: maroon">"instructions"</SPAN>] = [string]::join("`r`n",(<SPAN style="COLOR: #2b91af">gc</SPAN> <SPAN style="COLOR: #35687d">$file</SPAN>))}} 
<SPAN style="COLOR: green"># save changes back to SQL</SPAN> 
<SPAN style="COLOR: #2b91af">PS</SPAN> C:\demo&gt; .\save-datasetchanges.ps1 <SPAN style="COLOR: #35687d">$ds</SPAN> 
</PRE></DIV>
<P>Get-DataSet.ps1 stores the sql command and connection string used to create the dataset as extended properties on the dataset. This is used by Save-DataSetChanges.ps1 to construct a SqlCommandBuilder object;&nbsp;which is then used&nbsp;to create the update/insert/delete command objects&nbsp;and update the SQL Server using a SqlDataAdapter.</P>
<P><STRONG>get-dataset.ps1</STRONG>:</P><PRE class=code style="OVERFLOW: auto">param (<SPAN style="COLOR: #35687d">$sql</SPAN>,<SPAN style="COLOR: #35687d">$server</SPAN>=<SPAN style="COLOR: maroon">"."</SPAN>,<SPAN style="COLOR: #35687d">$db</SPAN>) 

<SPAN style="COLOR: #35687d">$connectionstring</SPAN>= <SPAN style="COLOR: maroon">"Server=$server;database=$db;trusted_connection=yes;"</SPAN> 
<SPAN style="COLOR: #35687d">$ds</SPAN> = <SPAN style="COLOR: #2b91af">new-object</SPAN> data.dataset 
<SPAN style="COLOR: #35687d">$da</SPAN> = <SPAN style="COLOR: #2b91af">New-Object</SPAN> system.data.sqlclient.sqldataadapter <SPAN style="COLOR: #35687d">$sql</SPAN>, <SPAN style="COLOR: #35687d">$connectionstring</SPAN> 
<SPAN style="COLOR: #35687d">$null</SPAN> = <SPAN style="COLOR: #35687d">$da</SPAN>.Fill(<SPAN style="COLOR: #35687d">$ds</SPAN>) 
<SPAN style="COLOR: #35687d">$ds</SPAN>.ExtendedProperties[<SPAN style="COLOR: maroon">"sql"</SPAN>]= <SPAN style="COLOR: #35687d">$sql</SPAN> 
<SPAN style="COLOR: #35687d">$ds</SPAN>.ExtendedProperties[<SPAN style="COLOR: maroon">"connectionstring"</SPAN>]= <SPAN style="COLOR: #35687d">$connectionstring</SPAN> 
<SPAN style="COLOR: #35687d">$ds</SPAN></PRE>
<P><STRONG>save-datasetchanges.ps1</STRONG>:</P><PRE class=code style="OVERFLOW: auto">param ([system.data.dataset]<SPAN style="COLOR: #35687d">$dataset</SPAN>)  

<SPAN style="COLOR: #35687d">$ds</SPAN> = <SPAN style="COLOR: #35687d">$dataset</SPAN> 
<SPAN style="COLOR: #35687d">$da</SPAN> = <SPAN style="COLOR: #2b91af">New-Object</SPAN> system.data.sqlclient.sqldataadapter <SPAN style="COLOR: #35687d">$ds</SPAN>.ExtendedProperties[<SPAN style="COLOR: maroon">"sql"</SPAN>], <SPAN style="COLOR: #35687d">$ds</SPAN>.ExtendedProperties[<SPAN style="COLOR: maroon">"connectionstring"</SPAN>] 

<SPAN style="COLOR: #35687d">$cb</SPAN> = <SPAN style="COLOR: #2b91af">new-object</SPAN> system.data.sqlclient.sqlcommandbuilder <SPAN style="COLOR: #35687d">$da</SPAN> 
<SPAN style="COLOR: #35687d">$da</SPAN>.UpdateCommand = <SPAN style="COLOR: #35687d">$cb</SPAN>.GetUpdateCommand() 
<SPAN style="COLOR: #35687d">$da</SPAN>.InsertCommand = <SPAN style="COLOR: #35687d">$cb</SPAN>.GetInsertCommand() 
<SPAN style="COLOR: #35687d">$da</SPAN>.DeleteCommand = <SPAN style="COLOR: #35687d">$cb</SPAN>.GetDeleteCommand() 
<SPAN style="COLOR: #35687d">$null</SPAN> = <SPAN style="COLOR: #35687d">$da</SPAN>.Update(<SPAN style="COLOR: #35687d">$ds</SPAN>) 
</PRE>]]></content:encoded>
    </item>
    <item>
      <title>Capturing SQL Generated by SMO in Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/capturing-sql-generated-by-smo-in-powershell</link>
      <pubDate>Sat, 24 Feb 2007 22:30:00 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/02/24/capturing-sql-generated-by-smo-in-powershell/</guid>
      <description><![CDATA[The following example uses the get-sqlserver.ps1 script in my search path. get-sqlserver.ps1: param...]]></description>
      <content:encoded><![CDATA[<p>The following example uses the get-sqlserver.ps1 script in my search path.</p> <p><strong>get-sqlserver.ps1:<br></strong></p> <div class="code" style="overflow: auto"><pre>param (<span style="color: #35687d">$server</span>=<span style="color: maroon">"."</span>)  
<span style="color: #35687d">$null</span> = [reflection.assembly]::loadwithpartialname(<span style="color: maroon">"microsoft.sqlserver.smo"</span>) 
<span style="color: #2b91af">new-object</span> Microsoft.SqlServer.Management.Smo.Server <span style="color: #35687d">$server</span>;</pre></div>
<p>This example will shows how to use SMO objects to generate a SQL Script that will drop all the rowguid columns from the adventure works database:</p>
<div class="code" style="overflow: auto"><pre><span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: #35687d">$srv</span> = get-sqlserver  
<span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: #35687d">$db</span> = <span style="color: #35687d">$srv</span>.Databases[<span style="color: maroon">"adventureworks"</span>] 
<span style="color: green"># Find the tables that have a rowguid column</span> 
<span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: blue">foreach</span> (<span style="color: #35687d">$tbl</span> <span style="color: blue">in</span> <span style="color: #35687d">$db</span>.tables) {<span style="color: #35687d">$tbl</span>.columns | %{ <span style="color: blue">if</span>(<span style="color: #35687d">$_</span>.name -eq <span style="color: maroon">"rowguid"</span>) {<span style="color: #35687d">$tbl</span>.name}}} 
Employee 
EmployeeAddress 
Address 
AddressType 
Contact 
StateProvince 
Product 
... 

<span style="color: green"># set SMO connection to capture mode</span> 
<span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: #35687d">$srv</span>.ConnectionContext.SqlExecutionModes = [Microsoft.SqlServer.Management.Common.SqlExecutionModes]::capturesql 

<span style="color: green"># drop the row guid column &amp; alter the table </span> 
<span style="color: green">#  SMO is set to capture only so the database is not updated</span> 
<span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: blue">foreach</span> (<span style="color: #35687d">$tbl</span> <span style="color: blue">in</span> <span style="color: #35687d">$db</span>.tables) {<span style="color: #35687d">$tbl</span>.columns | %{ <span style="color: blue">if</span>(<span style="color: #35687d">$_</span>.name -eq <span style="color: maroon">"rowguid"</span>) {<span style="color: #35687d">$_</span>.drop();<span style="color: #35687d">$tbl</span>.alter();}}} 
<span style="color: #2b91af"><span style="color: green"><br># Check the captured sql<br></span></span><span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: #35687d">$srv</span>.ConnectionContext.CapturedSql.Text 
USE [adventureworks] 
ALTER TABLE [HumanResources].[Employee] DROP CONSTRAINT [DF_Employee_rowguid] 
ALTER TABLE [HumanResources].[Employee] DROP COLUMN [rowguid] 
... 

<span style="color: green"># save the sql to a file</span> 
<span style="color: #2b91af">PS</span> C:\demo&gt; <span style="color: #35687d">$srv</span>.ConnectionContext.CapturedSql.Text | <span style="color: #2b91af">sc</span> update.sql 

</pre></div>]]></content:encoded>
    </item>
    <item>
      <title>EventTriggers</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/eventtriggers</link>
      <pubDate>Sat, 24 Feb 2007 15:51:31 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/02/24/eventtriggers/</guid>
      <description><![CDATA[This could be usefull; I always like knowing about obscure commands that are on every box I work...]]></description>
      <content:encoded><![CDATA[<p></p> <p>This could be usefull; I always like knowing about obscure commands that are on every box I work with. <p><b>eventtriggers</b>[<b>.exe</b>] <b>/create </b>[<b>/s </b><i>Computer</i> [<b>/u </b><i>Domain</i><b>\</b><i>User</i> [<b>/p </b><i>Password</i>]]] <b>/tr </b><i>TriggerName </i>[<b>/l</b> [<b>APPLICATION</b>] [<b>SYSTEM</b>] [<b>SECURITY</b>] [<b>"DNS&nbsp;Server"</b>] [<b>LOG</b>] [<i>DirectoryLogName</i>] [<b>*</b>]] {[<b>/eid </b><i>ID</i>] | [<b>/t</b> {<b>ERROR</b> | <b>INFORMATION</b> | <b>WARNING</b> | <b>SUCCESSAUDIT</b> | <b>FAILUREAUDIT</b>}] | [<b>/so </b><i>Source</i>]} [<b>/d </b><i>Description</i>] <b>/tk </b><i>TaskName</i>  <p><strong>eventtriggers create:<br></strong>This command creates a new event trigger that monitors and acts upon the occurrence of log events of given criteria.</p> <p><a title="https://technet2.microsoft.com/WindowsServer/en/library/e33bcf4c-dece-4b47-9bb7-31ecfcbc76d51033.mspx?mfr=true" href="https://technet2.microsoft.com/WindowsServer/en/library/e33bcf4c-dece-4b47-9bb7-31ecfcbc76d51033.mspx?mfr=true">https://technet2.microsoft.com/WindowsServer/en/library/e33bcf4c-dece-4b47-9bb7-31ecfcbc76d51033.mspx?mfr=true</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Connect to and Shadow the Console Session with Terminal Services</title>
      <link>https://docs.microsoft.com/archive/blogs/mwilbur/connect-to-and-shadow-the-console-session-with-terminal-services</link>
      <pubDate>Sat, 24 Feb 2007 15:44:07 GMT</pubDate>
      <dc:creator><![CDATA[mwilbur]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mwilbur/2007/02/24/connect-to-and-shadow-the-console-session-with-terminal-services/</guid>
      <description><![CDATA[This KB article shows how you have two separate TS sessions connected to the console:How to Connect...]]></description>
      <content:encoded><![CDATA[<p></p> <p>This KB article shows how you have two separate TS sessions connected to the console:</p><a href="https://support.microsoft.com/default.aspx?scid=kb;en-us;278845">How to Connect to and Shadow the Console Session with Windows Server 2003 Terminal Services</a>]]></content:encoded>
    </item>
  </channel>
</rss>