<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>PowerShell scripts</title>
        <link>http://geekswithblogs.net/EltonStoneman/category/8283.aspx</link>
        <description>PowerShell scripts</description>
        <language>en-GB</language>
        <copyright>EltonStoneman</copyright>
        <managingEditor>elton.stoneman@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>BizTalk Deployments with PowerShell</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/12/10/biztalk-deployments-with-powershell.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As part of my first look at &lt;a href="http://www.codeplex.com/esb/Release/ProjectReleases.aspx?ReleaseId=20234"&gt;ESB Guidance 2.0&lt;/a&gt; (which has some excellent enhancements which I'll post about shortly) I've been interested in the way the sample solutions are deployed. The P&amp;amp;P team have put together PowerShell scripts which take care of the usual things you'd find in a deployment scenario – stopping services, creating applications, adding resources and bindings.  &lt;/p&gt;
&lt;p&gt;In a Continuous Integration environment, you'd typically want to deploy to a BizTalk instance as part of the build process, to ensure the application configuration is valid, and as a prerequisite for running unit and integration tests. Currently I do this with MSBuild scripts using a variety of community, Sdc and custom tasks, and command-line tools. It makes for fragmented scripts that are difficult to read and maintain, and can be fragile to execute. &lt;/p&gt;
&lt;p&gt;In the PowerShell version a central script isolates the complexity for common functions, and then the individual install scripts use a neat, readable and hugely intuitive syntax. This is a complete install script for one of the sample solutions (&lt;em&gt;MultipleWebServices_install.ps1&lt;/em&gt;), which builds and then deploys the artifacts:&lt;span style="font-family: Courier New;"&gt; 		&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"..\.."&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: purple;"&gt;$samplesPath&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$solutionPath&lt;/span&gt;&lt;span style="color: red;"&gt;+&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\Samples\MultipleWebServices"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;. ..\..\..\..\&lt;/span&gt;&lt;span style="color: blue;"&gt;Core&lt;/span&gt;&lt;span style="color: black;"&gt;\&lt;/span&gt;&lt;span style="color: blue;"&gt;Install&lt;/span&gt;&lt;span style="color: black;"&gt;\&lt;/span&gt;&lt;span style="color: blue;"&gt;Scripts&lt;/span&gt;&lt;span style="color: black;"&gt;\&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;ESBFunctions.ps1&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: mediumblue;"&gt;BuildItinerarySolution &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;{ &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;param&lt;/span&gt;&lt;span style="color: black;"&gt;([&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;System.String&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;span style="color: purple;"&gt;$buildType&lt;/span&gt;&lt;span style="color: black;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &amp;amp;&lt;/span&gt;&lt;span style="color: purple;"&gt;$FrameworkPath&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\v3.5\MSBuild.exe"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\GlobalBank.ESB.Samples.MultipleWebServices.sln"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;/&lt;/span&gt;&lt;span style="color: blue;"&gt;t&lt;/span&gt;&lt;span style="color: black;"&gt;:&lt;/span&gt;&lt;span style="color: blue;"&gt;Rebuild&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;/&lt;/span&gt;&lt;span style="color: blue;"&gt;p&lt;/span&gt;&lt;span style="color: black;"&gt;:&lt;/span&gt;&lt;span style="color: blue;"&gt;Configuration&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: purple;"&gt;$buildType&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;BuildItinerarySolution&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;Debug&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;StopBTSApplication&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"Microsoft.Practices.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;StopBTSApplication&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"GlobalBank.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;StopBTSServices&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;ImportBTSResource&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"GlobalBank.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"BizTalkAssembly"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\Source\ESB.MultipleWebServices.Maps\bin\Debug\ESB.MultipleWebServices.Maps.dll"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;ImportBTSResource&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"GlobalBank.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"BizTalkAssembly"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\Source\ESB.MultipleWebServices.Orchestrations\bin\Debug\ESB.MultipleWebServices.Orchestrations.dll"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;GacOperation&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"-if"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\Source\ESB.MultipleWebServices.Maps\bin\Debug\ESB.MultipleWebServices.Maps.dll"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;GacOperation&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"-if"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: maroon;"&gt;"\Source\ESB.MultipleWebServices.Orchestrations\bin\Debug\ESB.MultipleWebServices.Orchestrations.dll"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;ImportBinding&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"GlobalBank.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$relativePath&lt;/span&gt;&lt;span style="color: black;"&gt;\&lt;/span&gt;&lt;span style="color: blue;"&gt;Install&lt;/span&gt;&lt;span style="color: black;"&gt;\&lt;/span&gt;&lt;span style="color: blue;"&gt;Binding&lt;/span&gt;&lt;span style="color: black;"&gt;\&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;GlobalBank.ESB.MultipleWebServices_Bindings.xml&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;StartBTSApplication&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"Microsoft.Practices.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;StartBTSApplication&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"GlobalBank.ESB"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-size: 9pt;"&gt;&lt;span style="color: blue; font-family: Courier New;"&gt;StartBTSServices&lt;/span&gt; 		&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The common script (&lt;em&gt;ESBFunctions.ps1&lt;/em&gt;) defines the main functions – &lt;em&gt;ImportBTSResource&lt;/em&gt; etc. – so the logic in the individual scripts is very clean. Common functions make use of PowerShell commands, the BizTalk Explorer OM, BTSTask and custom tools as appropriate, so there's still a variety of tools under the covers, but the common script is a facade over them all. This makes the install scripts neater and abstracts them from the actual implementation of the functions. Below are snippets for the functions to stop and to remove a BizTalk application: &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: mediumblue;"&gt;StopBTSApplication &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;{  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;param&lt;/span&gt;&lt;span style="color: black;"&gt;([&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: purple;"&gt;$exp&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;New-Object&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: purple;"&gt;$exp&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;ConnectionString&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$btsConnectionString&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: purple;"&gt;$app&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$exp&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;Applications&lt;/span&gt;&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt;] &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;$app&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;-eq&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$null&lt;/span&gt;&lt;span style="color: black;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;    { &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;        &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Write-Host&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"Application "&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;" not found"&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;-fore&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;Red&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;    } &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;    { &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;$app&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;Status&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;-ne&lt;/span&gt;&lt;span style="color: black;"&gt; 2) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;        { &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: green;"&gt;#full stop of application &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: purple;"&gt;$null&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$app&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;Stop&lt;/span&gt;&lt;span style="color: black;"&gt;(63) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: purple;"&gt;$null&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$exp&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;SaveChanges&lt;/span&gt;&lt;span style="color: black;"&gt;() &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;            &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Write-Host&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"Stopped application: "&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;        } &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;    } &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: mediumblue;"&gt;RemoveBTSApplication &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="color: black; font-family: Courier New; font-size: 9pt;"&gt;{  &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;param&lt;/span&gt;&lt;span style="color: black;"&gt;([&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;  &lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Write-Output&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: maroon;"&gt;"Removing BTS Application "&lt;/span&gt;&lt;span style="color: red;"&gt;+&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 9pt;"&gt;&lt;span style="color: black;"&gt;    &lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;BTSTask.exe&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;RemoveApp&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;/&lt;/span&gt;&lt;span style="color: blue;"&gt;A&lt;/span&gt;&lt;span style="color: black;"&gt;:&lt;/span&gt;&lt;span style="color: purple;"&gt;$appName&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-size: 9pt;"&gt;&lt;span style="color: black; font-family: Courier New;"&gt;}&lt;/span&gt; 		&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;There's some complexity in these common functions, but they're all tried and tested by the Patterns &amp;amp; Practices team. This is a new approach for the ESB Guidance installs (v1.0 used a combination of batch files to deploy the samples), but I don't think there are any inherent dependencies on BTS 2009 so this approach and the common script should work for BTS 2006 solutions. I'm going to look at migrating my current build scripts to this approach as it's so much simpler to work with, and the execution doesn't rely on chaining together unrelated tasks in MSBuild.  &lt;/p&gt;
&lt;p&gt;The ESBG samples specifically name resources to deploy, whereas my current scripts run dynamically over whichever artifacts they find, but Bart De Smet has a nice &lt;a href="http://bartdesmet.net/blogs/bart/archive/2008/02/16/invoking-powershell-scripts-from-msbuild.aspx"&gt;MSBuild task for running PowerShell scripts&lt;/a&gt;, which takes parameters so that's one option, and generating PS scripts using the &lt;a href="http://geekswithblogs.net/EltonStoneman/archive/2008/10/04/executet4template-msbuild-task-updated.aspx"&gt;ExecuteT4Template task&lt;/a&gt; is another. &lt;/p&gt;
&lt;p&gt;If I do get this running for BizTalk 2006 R2 solutions, I'll post a working set of sample scripts.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=127799"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=127799" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/127799.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/12/10/biztalk-deployments-with-powershell.aspx</guid>
            <pubDate>Thu, 11 Dec 2008 05:09:56 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/127799.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/12/10/biztalk-deployments-with-powershell.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/127799.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Corrupted Files on Virtual PC Disk</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2008/06/20/corrupted-files-on-virtual-pc-disk.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;One of the nice advantages of developing on a virtual image is that you can set it up with one drive for the OS and another for data. Your dev toolset is ready for project joiners to use, and copying a 15Gb file is far quicker than installing your toolset from nothing. When you want to take work home or on the train with you, it's just a case of zipping up the 1Gb data drive and copying it to your laptop. &lt;/p&gt;
&lt;p&gt;I've been doing this using Microsoft Virtual PC once or twice a day for the last few months, and it's somewhere like 99.99% faultless. But that 0.01% fault is manifested as random files being reduced to zero-bytes. They have the correct name and are in the expected location, but are missing their contents. So suddenly a project fails to build as one of the class files is empty.  &lt;/p&gt;
&lt;p&gt;This seems to be a result of occasionally resizing the .vhd file, rather than with repeatedly zipping and unzipping it. I haven't got an answer for the cause, but the following PowerShell script will output all the zero-length files you have on disk: &lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;##FindZeroByteFiles.ps1  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;param&lt;/span&gt;&lt;span style="color: black;"&gt;([&lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&lt;span style="color: black;"&gt;[]] &lt;/span&gt;&lt;span style="color: purple;"&gt;$paths&lt;/span&gt;&lt;span style="color: black;"&gt;)  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;function&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;Main&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: black; font-family: Courier New; font-size: 10pt;"&gt;{  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: purple;"&gt;$path&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$paths&lt;/span&gt;&lt;span style="color: black;"&gt;) {  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$list&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Join-Path&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$path&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;zeros.txt&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;Remove-Item&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$list&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;-ErrorAction&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;SilentlyContinue&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;get-childitem&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: purple;"&gt;$path&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: cadetblue;"&gt;-recurse&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;|&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;sort&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;Length&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;|&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt;&lt;span style="color: black;"&gt; {  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;          &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;&lt;span style="color: black;"&gt; (&lt;/span&gt;&lt;span style="color: navy;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;Length&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;-eq&lt;/span&gt;&lt;span style="color: black;"&gt; 0) {  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;span style="color: navy;"&gt;$_&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;span style="color: saddlebrown;"&gt;FullName&lt;/span&gt;&lt;span style="color: black;"&gt; &amp;gt;&amp;gt; &lt;/span&gt;&lt;span style="color: purple;"&gt;$list&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: black; font-family: Courier New; font-size: 10pt;"&gt;                        }  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: black; font-family: Courier New; font-size: 10pt;"&gt;                }  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: black; font-family: Courier New; font-size: 10pt;"&gt;        }  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: black; font-family: Courier New; font-size: 10pt;"&gt;}  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: black;"&gt;. &lt;/span&gt;&lt;span style="color: blue;"&gt;Main&lt;/span&gt;&lt;span style="color: black;"&gt; 			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;##&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;Usage – to list all the zero byte files on drives F and G: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;.\FindZeroByteFiles.ps1 F:\,G:\  &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This will output a file called &lt;strong&gt;zeros.txt&lt;/strong&gt; in the root of each drive specified.  &lt;/p&gt;
&lt;p&gt;I'll be running it more frequently and I'll update this post if I track down which part of the process is mangling those files in the virtual drive. Or if I get around to writing a heftier script which compares two virtual drives using &lt;a href="http://blogs.msdn.com/virtual_pc_guy/archive/2007/06/19/using-vhdmount-with-virtual-pc.aspx"&gt;VHDMount&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123043"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123043" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/123043.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2008/06/20/corrupted-files-on-virtual-pc-disk.aspx</guid>
            <pubDate>Sat, 21 Jun 2008 01:00:17 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/123043.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2008/06/20/corrupted-files-on-virtual-pc-disk.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/123043.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>