<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xml:base="http://www.red-gate.com/MessageBoard/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Red Gate forums: Deployment Manager PowerShell Scripts</title>
 <link>http://www.red-gate.com/MessageBoard/</link>
 <description>Product Support and Discussion</description>
 <language>en</language>
 <copyright>Copyright Red Gate Software Ltd</copyright>
 <managingEditor>internalsupport@red-gate.com</managingEditor>
 <webMaster>internalsupport@red-gate.com</webMaster>
 <docs>http://blogs.law.harvard.edu/tech/rss</docs>
 <ttl>60</ttl>
 <lastBuildDate>Thu, 20 Jun 2013 10:05:32 GMT</lastBuildDate>
 <pubDate>Thu, 20 Jun 2013 10:05:32 GMT</pubDate>
 <image>
  <url>http://www.red-gate.com/messageboard/templates/subRed/images/logo_phpBB.gif</url>
  <title>Red Gate forums: Deployment Manager PowerShell Scripts</title>
  <link>http://www.red-gate.com/MessageBoard/</link>
 </image>
 <item>
  <title>RE: Include custom SQL script output in DM's deployment logs</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=62324#62324</link>
  <description>Glad it works! I have moved this topic to Powershell scripts forum. 
&lt;br /&gt;

&lt;br /&gt;
Thanks!
&lt;br /&gt;

&lt;br /&gt;
Chirayu</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=17313</comments>
  <dc:creator>chirayu</dc:creator>
  <pubDate>Tue, 04 Jun 2013 07:56:13 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=62324#62324</guid>
 </item>
 <item>
  <title>RE: Include custom SQL script output in DM's deployment logs</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=62308#62308</link>
  <description>Hi Chirayu,
&lt;br /&gt;

&lt;br /&gt;
Your suggestion worked beautifully!
&lt;br /&gt;

&lt;br /&gt;
After adding 
&lt;br /&gt;

&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;| Out-Default&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
to the sqlmcd call, the script output is indeed captured by Deployment Manager.
&lt;br /&gt;

&lt;br /&gt;
Many thanks!
&lt;br /&gt;

&lt;br /&gt;
/Mattias</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=17313</comments>
  <dc:creator>swinghouse</dc:creator>
  <pubDate>Mon, 03 Jun 2013 22:04:09 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=62308#62308</guid>
 </item>
 <item>
  <title>RE: Include custom SQL script output in DM's deployment logs</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=62285#62285</link>
  <description>Hi Mattias,
&lt;br /&gt;

&lt;br /&gt;
Deployment Manager should be capturing the std-out output from powershell scripts. 
&lt;br /&gt;

&lt;br /&gt;
Windows powershell puts 'Out-Default' at the end of a pipeline, so what actually gets run is 
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;sqlcmd.exe &amp;lt;arguments&amp;gt; | Out-Default&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
Out-Default cannot process some objects. It &lt;span style=&quot;font-style: italic&quot;&gt;can only handle a special type of formatting object produced by the shell’s formatting subsystem&lt;/span&gt;, according to this article: 
&lt;br /&gt;
&lt;a href=&quot;http://technet.microsoft.com/en-us/magazine/gg213852.aspx&quot; target=&quot;_blank&quot;&gt;http://technet.microsoft.com/en-us/magazine/gg213852.aspx&lt;/a&gt;
&lt;br /&gt;

&lt;br /&gt;
Would you please run this command 
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;sqlcmd.exe &amp;lt;arguments&amp;gt; | Out-Default&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;
and check that it actually outputs something?
&lt;br /&gt;

&lt;br /&gt;
Thanks!
&lt;br /&gt;

&lt;br /&gt;
Chirayu</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=17313</comments>
  <dc:creator>chirayu</dc:creator>
  <pubDate>Mon, 03 Jun 2013 13:03:41 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=62285#62285</guid>
 </item>
 <item>
  <title>Include custom SQL script output in DM's deployment logs</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=62251#62251</link>
  <description>In one of our Deployment Manager (DM) projects we let PostDeploy.ps1 run a customized SQL script like so:
&lt;br /&gt;

&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;sqlcmd.exe -b -V 1 -s $databaseServer -U $databaseUserName -P $databasePassword -i &amp;quot;RunMigrationScript.sql&amp;quot; -d &amp;quot;$databaseName&amp;quot;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
This works, but it would be nice to have DM include the output (SQL Print statements in this case) from the SQL script file in the deployment log. Currently we get:
&lt;br /&gt;

&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Quote:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;quote&quot;&gt;2013-05-30 15:43:53 DEBUG  Looking for PowerShell scripts named PostDeploy.ps1
&lt;br /&gt;
2013-05-30 15:43:53 INFO   Calling PowerShell script&amp;#058; 'C:\ProgramData\Red Gate\DeploymentAgent\Applications\Production.Data\BagheraDataMigration\0.116\PostDeploy.ps1'
&lt;br /&gt;
2013-05-30 15:49:08 DEBUG  Script 'C:\ProgramData\Red Gate\DeploymentAgent\Applications\Production.Data\BagheraDataMigration\0.116\PostDeploy.ps1' completed.
&lt;br /&gt;
2013-05-30 15:49:08 DEBUG  Script output:
&lt;br /&gt;
2013-05-30 15:49:08 DEBUG
&lt;br /&gt;
2013-05-30 15:49:08 DEBUG  Return code of PowerShell script&amp;#058; 0&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
No script output in there!
&lt;br /&gt;

&lt;br /&gt;
Is it possible to get the script output in the DM deployment log? If so, what do we need to change?
&lt;br /&gt;

&lt;br /&gt;
/Mattias</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=17313</comments>
  <dc:creator>swinghouse</dc:creator>
  <pubDate>Fri, 31 May 2013 14:57:37 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=62251#62251</guid>
 </item>
 <item>
  <title>PowerShell script for shutting down a running exe</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=59594#59594</link>
  <description>This is probably basic stuff for many of you guys, but I got some really helpful assistance from the &amp;quot;Red Gaters&amp;quot; at &lt;a href=&quot;http://www.red-gate.com/MessageBoard/viewtopic.php?p=59593#59593&quot; target=&quot;_blank&quot;&gt;http://www.red-gate.com/MessageBoard/viewtopic.php?p=59593#59593&lt;/a&gt; when I needed to shut down an exe on the target machine before deploying an application to it.</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=16302</comments>
  <dc:creator>swinghouse</dc:creator>
  <pubDate>Thu, 03 Jan 2013 10:02:58 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=59594#59594</guid>
 </item>
 <item>
  <title>Share your PowerShell deployment scripts</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=59443#59443</link>
  <description>You can use this forum to share any PowerShell deployment scripts that you make, that you think will be useful to others.</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=16246</comments>
  <dc:creator>justin.caldicott</dc:creator>
  <pubDate>Fri, 14 Dec 2012 15:33:33 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=59443#59443</guid>
 </item>
 <item>
  <title>Windows Services</title>
  <link>http://www.red-gate.com/MessageBoard/viewtopic.php?p=59440#59440</link>
  <description>This script uses the Service Control tool (sc.exe) to create or update a Windows Service. It assumes some variables have been set in the Deployment Manager web interface:
&lt;br /&gt;

&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;
&lt;br /&gt;
# These variables should be set via the Deployment Manager web interface&amp;#58;
&lt;br /&gt;
#
&lt;br /&gt;
# ServiceName - Name of the Windows service
&lt;br /&gt;
# ServiceExecutable - Path to the .exe containing the service
&lt;br /&gt;
#
&lt;br /&gt;
# sc.exe is the Service Control utility in Windows
&lt;br /&gt;
$service = Get-Service $ServiceName -ErrorAction SilentlyContinue
&lt;br /&gt;
$fullPath = Resolve-Path $ServiceExecutable
&lt;br /&gt;
if &amp;#40;! $service&amp;#41;
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; Write-Host &amp;quot;The service will be installed&amp;quot;
&lt;br /&gt;
&amp;nbsp; New-Service -Name $ServiceName -BinaryPathName $fullPath -StartupType Automatic
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;
else
&lt;br /&gt;
&amp;#123;
&lt;br /&gt;
&amp;nbsp; Write-Host &amp;quot;The service will be stopped and reconfigured&amp;quot;
&lt;br /&gt;
&amp;nbsp; Stop-Service $ServiceName -Force
&lt;br /&gt;
&amp;nbsp; &amp;amp; &amp;quot;sc.exe&amp;quot; config $service.Name binPath= $fullPath start= auto | Write-Host
&lt;br /&gt;
&amp;#125;
&lt;br /&gt;
Write-Host &amp;quot;Starting the service&amp;quot;
&lt;br /&gt;
Start-Service $ServiceName
&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
This script uses InstallUtil.exe to install custom Event Log sources and Windows Services:
&lt;br /&gt;

&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;
&lt;br /&gt;
$NetFrameworkDirectory = $&amp;#40;&amp;#91;System.Runtime.InteropServices.RuntimeEnvironment&amp;#93;&amp;#58;&amp;#58;GetRuntimeDirectory&amp;#40;&amp;#41;&amp;#41;
&lt;br /&gt;
&amp;amp; &amp;#40;Join-Path $NetFrameworkDirectory &amp;quot;InstallUtil.exe&amp;quot;&amp;#41; &amp;quot;path\to\my.dll&amp;quot; | Write-Host
&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
  <category>Deployment Manager PowerShell Scripts</category>
  <comments>http://www.red-gate.com/MessageBoard/posting.php?mode=reply&amp;t=16244</comments>
  <dc:creator>justin.caldicott</dc:creator>
  <pubDate>Fri, 14 Dec 2012 14:57:19 GMT</pubDate>
  <guid isPermaLink="true">http://www.red-gate.com/MessageBoard/viewtopic.php?p=59440#59440</guid>
 </item>
</channel>
</rss>
