<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>Max Trinidad - The PowerShell Front</title>
	
	<link>http://www.maxtblog.com</link>
	<description>A little of everything about PowerShell!!!</description>
	<lastBuildDate>Fri, 27 Apr 2012 19:53:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MaxTrinidad-ThePowershellFront" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="maxtrinidad-thepowershellfront" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">MaxTrinidad-ThePowershellFront</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>PowerShell V3.0 Object difference vs V2.0…‏</title>
		<link>http://www.maxtblog.com/2012/04/powershell-v3-0-object-difference-vs-v2-0-%e2%80%8f/</link>
		<comments>http://www.maxtblog.com/2012/04/powershell-v3-0-object-difference-vs-v2-0-%e2%80%8f/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 19:53:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1209</guid>
		<description><![CDATA[I was unconsciously doing something while coding in PowerShell V3.0 Beta, and it caught me off guard.  As I&#8217;m getting more comfortable working with PowerShell Objects, I didn&#8217;t realized there is an enhancement in place.  There&#8217;s a quick way to &#8230; <a href="http://www.maxtblog.com/2012/04/powershell-v3-0-object-difference-vs-v2-0-%e2%80%8f/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was unconsciously doing something while coding in PowerShell V3.0 Beta, and it caught me off guard.  As I&#8217;m getting more comfortable working with PowerShell Objects, I didn&#8217;t realized there is an enhancement in place.  There&#8217;s a quick way to access with your objects values. I&#8217;m trying to scripting for PowerShell V2.0 but I started see errors, then I realize I was accessing my items differently in PowerShell V3.0.</p>
<p>Let me show some PowerShell V3.0 code that access a SQL Server SMO collection of type &#8220;Microsoft.SqlServer.Management.Smo.Information&#8221;.  I want to access the values of the property &#8220;Properties&#8221; in the SQL Server Information SMO Object.</p>
<p><em>*hint*: Remember to use the command &#8220;Get-Member&#8221; to expose the content (method &amp; properties) in your PowerShell variable.</em></p>
<pre class="brush: powershell; title: ; notranslate">

## - Load Assembly and create your SQL object:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.SQLServer.SMO&quot;);
$MySQL = New-Object('Microsoft.SqlServer.Management.SMO.Server');

## - Getting to your Information Properties&quot;
$MySQL.Information;
$MySQL.Information.Properties;
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfo01.png"><img class="aligncenter size-full wp-image-1215" title="GetSQLInfo01" src="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfo01.png" alt="" width="987" height="725" /></a></p>
<p>The last two lines will give you some results back. Now, try the next line:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Only valid in PowerShell V3.0:
$MySQL.Information.Properties.name;
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfoV32.png"><img class="aligncenter size-full wp-image-1221" title="GetSQLInfoV3" src="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfoV32.png" alt="" width="1001" height="470" /></a>This line will display all values in the property &#8220;Name&#8221;, and that&#8217;s great.</p>
<p>Go to another machine with PowerShell V2.0, and execute the lines:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Load Assembly and create your SQL object:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.SQLServer.SMO&quot;);
$MySQL = New-Object('Microsoft.SqlServer.Management.SMO.Server');

## - Only valid in PowerShell V3.0:
$MySQL.Information.Properties.name;
</pre>
<p>Notice you will not get any results back.</p>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfo03.png"><img class="aligncenter size-full wp-image-1218" title="GetSQLInfo03" src="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfo03.png" alt="" width="680" height="526" /></a>Now, change the line below and the execute:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Valid in both PowerShell V3.0 and V2.0:
$MySQL.Information.Properties | Select name;
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfo04.png"><img class="aligncenter size-full wp-image-1219" title="GetSQLInfo04" src="http://www.maxtblog.com/wp-content/uploads/2012/04/GetSQLInfo04.png" alt="" width="728" height="381" /></a>And, it will display all values from this property.</p>
<p>As you notice, using PowerShell V3.0 can list items from the collection without forcing you to pipe &#8220;|&#8221; the value to another command (&#8220;<span style="color: #0000ff;"><em>.. | Select Name ..</em></span>&#8220;). Just be careful and make sure the code stay compatible with PowerShell V2.0.</p>
<p>I like this enhancement!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/04/powershell-v3-0-object-difference-vs-v2-0-%e2%80%8f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PragmaticWorks Webinar: Basic Intro to PowerShell for the DBA – agenda</title>
		<link>http://www.maxtblog.com/2012/04/pragmaticworks-webinar-basic-intro-to-powershell-for-the-dba-agenda/</link>
		<comments>http://www.maxtblog.com/2012/04/pragmaticworks-webinar-basic-intro-to-powershell-for-the-dba-agenda/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 13:35:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1203</guid>
		<description><![CDATA[Yes! Today, Tuesday April 17th at 11:00am EST on PragmaticWorks Webinar, I will be speaking doing a session on &#8220;Basic Intro to PowerShell for the DBA&#8220;. This is an introduction to what you need in order to start using PowerShell &#8230; <a href="http://www.maxtblog.com/2012/04/pragmaticworks-webinar-basic-intro-to-powershell-for-the-dba-agenda/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yes! Today, Tuesday April 17th at 11:00am EST on PragmaticWorks Webinar, I will be speaking doing a session on &#8220;<a title="Webinar link to &quot;Basic Intro to PowerShell for the DBA&quot;" href="http://pragmaticworks.com/Resources/webinars/Default.aspx" target="_blank">Basic Intro to PowerShell for the DBA</a>&#8220;. This is an introduction to what you need in order to start using PowerShell in your SQL Server environment.</p>
<p>Here&#8217;s the agenda for this session:</p>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/04/IntroAgenda.png"><img class="aligncenter size-full wp-image-1204" title="IntroAgenda" src="http://www.maxtblog.com/wp-content/uploads/2012/04/IntroAgenda.png" alt="" width="846" height="637" /></a></p>
<p>Hopefully, this material will help you get you started to learn PowerShell all your automation needs.<br />
And, YES!! Here&#8217;s some few scripts to get you started:<br />
<iframe title ="Preview" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" width="98px" height="120px" style="padding:0;background-color:#fcfcfc;" src="https://skydrive.live.com/embed?cid=7FD7082276C66197&#038;resid=7FD7082276C66197%21406&#038;authkey=ACcIcblfDupRkCo"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/04/pragmaticworks-webinar-basic-intro-to-powershell-for-the-dba-agenda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting BizTalk information with PowerShell</title>
		<link>http://www.maxtblog.com/2012/04/getting-biztalk-information-with-powershell/</link>
		<comments>http://www.maxtblog.com/2012/04/getting-biztalk-information-with-powershell/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 18:54:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1181</guid>
		<description><![CDATA[As I keep venturing into Biztalk, here&#8217;s how you can start using PowerShell to access your BizTalk objects with just a few lines of code and (for now) using one of the BizTalk .NET assemblies that&#8217;s loaded during the installation. In &#8230; <a href="http://www.maxtblog.com/2012/04/getting-biztalk-information-with-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As I keep venturing into Biztalk, here&#8217;s how you can start using PowerShell to access your BizTalk objects with just a few lines of code and (for now) using one of the BizTalk .NET assemblies that&#8217;s loaded during the installation.</p>
<p>In the following example, I will create a PowerShell .NET object containing information about my BizTalk Application Artifacts. Please, pay attention to these sample code. There&#8217;s lots of information in it.</p>
<p>Open a PowerShell Console prompt, and type (or copy/paste) the following code:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Load the following Assembly:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.BizTalk.ExplorerOM&quot;);

## - Create a new empty variable to stored the .NET information:
$BTSexp = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer;

## - Now, this line will connect to your Biztalk Local instance:
$BTSexp.ConnectionString = &quot;Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;&quot;;
</pre>
<p>Now, keep in mind, you need to execute this block of code in your BizTalk server box, or use PowerShell Remoting feature. To look into the newly created object &#8216;$BTSexp&#8217;, use the &#8220;Get-Member&#8221; command to expose all the .NET object stored in it. You&#8217;ll notice both Properties, and Methods:</p>
<pre class="brush: powershell; title: ; notranslate">

$BTSexp | Get-member;
</pre>
<p>As you can see, few line of code,  you got a lot of information about you BizTalk box. Try the following lines to list all our send box:</p>
<pre class="brush: powershell; title: ; notranslate">

$BTSexp.Sendports
</pre>
<p>This line will display all properties and its content on the screen.  Now, using the &#8220;Get-Member&#8221; (or &#8220;GM&#8221;) command, you can select from these list some of the properties you want to display on screen:</p>
<pre class="brush: powershell; title: ; notranslate">
## - List all Biztalk .NET object properties and methods:
$BTSexp.SendPorts | gm;

## - Display some of the selected properties:
$BTSexp.SendPorts | Select Application, name, Status | format-table -auto;

## - The End
</pre>
<p>Oops!! Notice our result is not exactly correct. Our &#8216;Application&#8217; values are showing with a long .NET Namespace, and our status column got truncated from the list.  The &#8216;Application&#8217; property is another .NET object that contains more information, and is only accessible if you use the &#8216;Foreach&#8217; loop condition to get to it.</p>
<p>To fix this oneliner, we need to create a loop block so we can go deep into the .NET object of &#8216;Application&#8217; and extract that information. The example below I added an &#8220;if&#8221; statement to search for all SendPorts containing the &#8216;TransportType&#8217; for FTP&#8217;s:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Load the following Assembly:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.BizTalk.ExplorerOM&quot;);

## - Create a new empty variable to stored the .NET information:
$BTSexp = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer;

## - Now, this line will connect to your Biztalk Local instance:
$BTSexp.ConnectionString = `
  &quot;Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;&quot;;
## - Looping through each item in the SendPorts object and display
## - it in the PowerShell console:
$y = 0;
foreach($item in ($BTSexp.SendPorts))
{
    if($item.PrimaryTransport -ne $null)
    {
        if($item.PrimaryTransport.TransportType.Name -match &quot;FTP|Nsoftware SFTP&quot;)
        {
            Write-host &quot;[$($y.ToString(&quot;000&quot;))]`t$($item.Application.name)`t$($item.PrimaryTransport.TransportType.Name)`t$($item.Name)&quot;;
            $y++;
        }
    }
};
</pre>
<p>Well, we are getting better now but we can make it look nicer. Adding a few more lines we change the code to store the values generated into a PowerShell PSObject. Finally, we can generate a better formatted result:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Load the following Assembly:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.BizTalk.ExplorerOM&quot;);

## - Create a new empty variable to stored the .NET information:
$BTSexp = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer;

## - Now, this line will connect to your Biztalk Local instance:
$BTSexp.ConnectionString = `
  &quot;Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;&quot;;

## - Initialize variables:
$y = 0; [Array] $MyNewObject = $null;

#Add each result into our New object:
$MyNewObject = foreach($item in ($BTSexp.SendPorts))
{
    if($item.PrimaryTransport -ne $null)
    {
        if($item.PrimaryTransport.TransportType.Name -match &quot;FTP&quot;)
        {
           #Building your PowerShell PSObject item:
    $newPSitem = New-Object PSObject -Property @{
         seq = $y.ToString(&quot;000&quot;);
  Application = $item.Application.name;
                PortType = $item.PrimaryTransport.TransportType.Name;
                Port = $item.Name;
           };
           #To display PSObject item values while processing:
           $newPSitem;
           $y++;
        }
    }
};
$MyNewObject | Select seq,Application,PortType,Port | ft -auto;
</pre>
<p>Now, we&#8217;ve created a new PowerShell object with our selected properties, and with a new output that looks Great!. Just Try It in your box!!</p>
<p>The above script will list all FTP related ports. Here&#8217;s another the same code PowerShell script for listing all SendPorts on your BizTalk Server:</p>
<pre class="brush: powershell; title: ; notranslate">

## - Load the following Assembly:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.BizTalk.ExplorerOM&quot;);

## - Create a new empty variable to stored the .NET information:
$BTSexp = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer;

## - Now, this line will connect to your Biztalk Local instance:
$BTSexp.ConnectionString = `
  &quot;Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;&quot;;

## - Initialize variables:
$y = 0; [Array] $MyNewObject = $null;

## - Initialize variables:
$y = 0; [Array] $MyNewObject = $null;

#Add each result into our New object:
$MyNewObject = foreach($item in ($BTSexp.SendPorts))
{
 #Building your PowerShell PSObject item:
    $newPSitem = New-Object PSObject -Property @{
  seq = $y.ToString(&quot;000&quot;);
  Application = $item.Application.name;
  PortType = $item.PrimaryTransport.TransportType.Name;
  Port = $item.Name;
 };
 #To display PSObject item values while processing:
 $newPSitem;
 $y++;
};
$MyNewObject | Select seq,Application,PortType,Port | ft -auto;
</pre>
<p>Now, you can get a list of all your sendPorts. Don&#8217;t be afraid to experiment. You are only querying BizTalk objects using PowerShell.</p>
<p>My next blog will show this query use to list all ReceivePorts.</p>
<p>Happy PowerShelling!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/04/getting-biztalk-information-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Orlando Code Camp 2012 – Integrating PowerShell into SSIS Script Task session</title>
		<link>http://www.maxtblog.com/2012/03/orlando-code-camp-2012-integrating-powershell-into-ssis-script-task-session/</link>
		<comments>http://www.maxtblog.com/2012/03/orlando-code-camp-2012-integrating-powershell-into-ssis-script-task-session/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 17:55:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1160</guid>
		<description><![CDATA[I took the moment posted the session I&#8217;ll be presenting at the Orlando Code Camp 2012 on Saturday March 31.  In this session I&#8217;ll be covering PowerShell, XML, Visual Studio Application, and integration these technologies in SQL Server Integration Services.  &#8230; <a href="http://www.maxtblog.com/2012/03/orlando-code-camp-2012-integrating-powershell-into-ssis-script-task-session/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I took the moment posted the session I&#8217;ll be presenting at the Orlando Code Camp 2012 on Saturday March 31.  In this session I&#8217;ll be covering PowerShell, XML, Visual Studio Application, and integration these technologies in SQL Server Integration Services.  I&#8217;ll be reusing an existing Powershell script in a SSIS Script Task component.</p>
<div id="attachment_1162" class="wp-caption aligncenter" style="width: 694px"><a href="http://www.maxtblog.com/wp-content/uploads/2012/03/xmlPowerShellscript.png"><img class="size-full wp-image-1162" title="xmlPowerShellscript" src="http://www.maxtblog.com/wp-content/uploads/2012/03/xmlPowerShellscript.png" alt="" width="684" height="89" /></a><p class="wp-caption-text">sample PowerShell Script</p></div>
<div id="attachment_1164" class="wp-caption aligncenter" style="width: 839px"><a href="http://www.maxtblog.com/wp-content/uploads/2012/03/xmlSSISscriptTask1.png"><img class="size-full wp-image-1164" title="xmlSSISscriptTask" src="http://www.maxtblog.com/wp-content/uploads/2012/03/xmlSSISscriptTask1.png" alt="" width="829" height="78" /></a><p class="wp-caption-text">Using the PowerShell script in SSIS Script Task</p></div>
<div id="attachment_1165" class="wp-caption aligncenter" style="width: 792px"><a href="http://www.maxtblog.com/wp-content/uploads/2012/03/SSIS_PowerShell_ScriptTask01.png"><img class="size-full wp-image-1165" title="SSIS_PowerShell_ScriptTask01" src="http://www.maxtblog.com/wp-content/uploads/2012/03/SSIS_PowerShell_ScriptTask01.png" alt="" width="782" height="441" /></a><p class="wp-caption-text">SQL Server 2012 SSIS package</p></div>
<div id="attachment_1173" class="wp-caption aligncenter" style="width: 971px"><a href="http://www.maxtblog.com/wp-content/uploads/2012/03/SSIS_PowerShell_ScriptTask022.png"><img class="size-full wp-image-1173" title="SSIS_PowerShell_ScriptTask02" src="http://www.maxtblog.com/wp-content/uploads/2012/03/SSIS_PowerShell_ScriptTask022.png" alt="" width="961" height="534" /></a><p class="wp-caption-text">SSIS Script Task section executing the PowerShell code</p></div>
<p>This session is full sample: XML files, PowerShell scripts, VB/C# code for both Visual Studio and SSIS Script Task showing some basic techniques.</p>
<p>For those attending this event, I hope to see you at my session.<br />
<iframe style="padding: 0px; background-color: #fcfcfc;" title="Preview" src="https://skydrive.live.com/embed?cid=7FD7082276C66197&amp;resid=7FD7082276C66197%21402&amp;authkey=AIZjGqyQc5lqw3M" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="98" height="120"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/03/orlando-code-camp-2012-integrating-powershell-into-ssis-script-task-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Me, PowerShell, and BizTalk…</title>
		<link>http://www.maxtblog.com/2012/03/me-powershell-and-biztalk/</link>
		<comments>http://www.maxtblog.com/2012/03/me-powershell-and-biztalk/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 19:35:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1140</guid>
		<description><![CDATA[For many years, I&#8217;ve been a PowerShell enthusiast exposed to Network Infrastructure and SQL Server technologies.  Now I&#8217;ve become a BizTalk newbie.  And, with my responsibility as a BizTalk Developer, and I attended a BizTalk Server class online.  For my surprise, in one of the modules, &#8230; <a href="http://www.maxtblog.com/2012/03/me-powershell-and-biztalk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For many years, I&#8217;ve been a PowerShell enthusiast exposed to Network<br />
Infrastructure and SQL Server technologies.  Now I&#8217;ve become a BizTalk<br />
newbie.  And, with my responsibility as a BizTalk Developer, and I attended a BizTalk Server class online.  For my surprise, in one of the modules, instructor talked about a PowerShell Shell script .  I just hope the script hasn&#8217;t scare anyone attending the course.</p>
<p>PowerShell is much easier, and fun work once you start using it.  Try to ignore using cmd.exe, and start using PowerShell.   Try it!!   For example try to execute the <strong>BTStask.exe</strong> command.</p>
<p>The following sample will save the output console results to a PowerShell variable:</p>
<pre class="brush: powershell; title: ; notranslate">
$myBTStask = BTStask.exe ListApps
$myBTStask
</pre>
<p>Notice I&#8217;ve create my variable &#8220;$MyBTStask&#8221;, and now I can  extract some information stored in it.  For example, I only want to list all application information:</p>
<pre class="brush: powershell; title: ; notranslate">
$MyBTStask | where{$_ -match '-Appl'}
</pre>
<div id="attachment_1158" class="wp-caption aligncenter" style="width: 1000px"><a href="http://www.maxtblog.com/wp-content/uploads/2012/03/BTStask_3-27-2012-3-29-02-PM1.png"><img class="size-full wp-image-1158" title="BTStask_3-27-2012 3-29-02 PM" src="http://www.maxtblog.com/wp-content/uploads/2012/03/BTStask_3-27-2012-3-29-02-PM1.png" alt="" width="990" height="639" /></a><p class="wp-caption-text">Executing &quot;BTStask.exe&quot; from the PowerShell Console</p></div>
<p>Now, you can evolved in this simple script into something more sophisticated.</p>
<p>I&#8217;m always looking for ways to help me be productive in my  work environment.  So, I found a couple following CodePlex projects, and PowerShell was included:</p>
<p>BizTalk 2010 Web Console: <a href="http://abdulrafaysbiztalk.wordpress.com/" target="_blank">http://abdulrafaysbiztalk.<wbr>wordpress.com/</wbr></a><br />
PowerShell BizTalk provider: <a href="http://psbiztalk.codeplex.com/" target="_blank">http://psbiztalk.codeplex.com/</a></p>
<p>And, there&#8217;s more codeplex BizTalk project out there.  Also, there&#8217;s some very thorough BizTalk Training Kits available from Microsoft, include Videos, Labs, and Virtual machines.  But you will to use  Microsoft Hyper-V Virtualization Technology:</p>
<p>BizTalk Server 2010 Developer Training Kit: <a href="http://www.microsoft.com/download/en/details.aspx?id=14865" target="_blank">http://www.microsoft.com/<wbr>download/en/details.aspx?id=<wbr>14865</wbr></wbr></a><br />
BizTalk Server 2010 Administrator Training Kit: <a href="http://www.microsoft.com/download/en/details.aspx?id=27148" target="_blank">http://www.microsoft.com/<wbr>download/en/details.aspx?id=<wbr>27148</wbr></wbr></a></p>
<p>BizTalk Server 2010 ESB Training Kit: <a href="http://www.microsoft.com/download/en/details.aspx?id=27151" target="_blank">http://www.microsoft.com/<wbr>download/en/details.aspx?id=<wbr>27151</wbr></wbr></a></p>
<p>So, in my case I use my laptop with Windows 8 Server w/Hyper-V 3.0 and it works GREAT!!</p>
<p>Now, I&#8217;m used to work with SQL Server so it makes sanse to me to  explore the possibilities of using PowerShell to help with my BizTalk  Administration.  So, I can check for my Biztalk table in my SQL Server  local instance in the following way:</p>
<pre class="brush: powershell; title: ; notranslate">
## - Listing your local Databases:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.SQLServer.SMO&quot;)
$MySQL = New-Object('Microsoft.SqlServer.Management.SMO.Server')
$MySQL.Databases | Select Name, owner, Size | Ft -auto
</pre>
<p>Also, I could list all my SQL Agent jobs with the following generic PowerShell script:</p>
<pre class="brush: powershell; title: ; notranslate">
## - Listing your SQL Agent jobs:
[System.Reflection.Assembly]::loadwithPartialName(&quot;Microsoft.SQLServer.SMO&quot;)
$MySQL = New-Object('Microsoft.SqlServer.Management.SMO.Server')
$MySQL.JobServer.Jobs | Select name, isenabled, lastrundate, lastRunOutcome | ft -auto
</pre>
<p>As you can see, these little simple oneliners you can give lots of  information about your Biztalk box.  This is all executed on your box  which might bring the question: Can I do execute PowerShell script in  another BizTalk box? And the answer is: YES!! But it all depends if your  IT organization will allow it.</p>
<p>Keep in mind, you need to have the proper permissions to allow you to  access these SQL server box.  In the meantime, if you have your on  Virtual Machine, at least you can practice show management how they can  benefit from using PowerShell.</p>
<p>Happy PowerShelling!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/03/me-powershell-and-biztalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Tampa SQLSaturday “PowerShell Query for the T-SQL Developer” session…</title>
		<link>http://www.maxtblog.com/2012/03/my-tampa-sqlsaturday-powershell-query-for-the-t-sql-developer-session/</link>
		<comments>http://www.maxtblog.com/2012/03/my-tampa-sqlsaturday-powershell-query-for-the-t-sql-developer-session/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 03:26:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1134</guid>
		<description><![CDATA[Here&#8217;s my sample queries for both PowerShell and T-SQL scripts.  I also included a basic comparison chart created in excel. Click link to download presentation: Thanks to everyone for attending my session!]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s my sample queries for both PowerShell and T-SQL scripts.  I also included a basic comparison chart created in excel.</p>
<p>Click link to download presentation:<iframe style="padding: 0pt; background-color: #fcfcfc;" title="Preview" src="https://skydrive.live.com/embed?cid=7FD7082276C66197&amp;resid=7FD7082276C66197%21394&amp;authkey=AJFdDjqnA2L4_EA" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="98px" height="120px"></iframe></p>
<p>Thanks to everyone for attending my session!</p>
<div id="attachment_1135" class="wp-caption aligncenter" style="width: 1061px"><a href="http://www.maxtblog.com/wp-content/uploads/2012/03/PowerShellQueryvsTSQLComparison.png"><img class="size-full wp-image-1135" title="PowerShellQueryvsTSQLComparison" src="http://www.maxtblog.com/wp-content/uploads/2012/03/PowerShellQueryvsTSQLComparison.png" alt="" width="1051" height="603" /></a><p class="wp-caption-text">PowerShell Query vs T-SQL Comparison</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/03/my-tampa-sqlsaturday-powershell-query-for-the-t-sql-developer-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL &amp; PowerShell – Another way to Identify Database Snapshots</title>
		<link>http://www.maxtblog.com/2012/02/tsql-powershell-another-way-to-identify-database-snapshots/</link>
		<comments>http://www.maxtblog.com/2012/02/tsql-powershell-another-way-to-identify-database-snapshots/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 18:57:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1079</guid>
		<description><![CDATA[Just a quick blog on spotting your Database Snaphots. I just couldn&#8217;t believe that I&#8217;ve been missing creating SQL database snapshots but sometimes having so much work make you blind.  I&#8217;ve been using a lot Hyper-V Snapshot features and recently &#8230; <a href="http://www.maxtblog.com/2012/02/tsql-powershell-another-way-to-identify-database-snapshots/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just a quick blog on spotting your Database Snaphots. I just couldn&#8217;t believe that I&#8217;ve been missing creating SQL database snapshots but sometimes having so much work make you blind.  I&#8217;ve been using a lot Hyper-V Snapshot features and recently (Thanks to <a href="http://sev17.com/" target="_blank">Chad Miller</a>) I got the chance to create and test a few.</p>
<p>So, first we need to create a new db snapshot of my AdventureWorks database using T-SQL Script:</p>
<pre class="brush: sql; title: ; notranslate">
CREATE DATABASE AdventureWorks_dbSnapShot_0001 ON
( NAME = AdventureWorks_Data, FILENAME =
'C:\Program Files\Microsoft SQL Server\MSSQL11.MSQLDENALICTP3\MSSQL\DATA\AdventureWorks_Data_0001.ss' )
AS SNAPSHOT OF AdventureWorks;
GO
</pre>
<p>Now, I go to SSMS and verify my new database snapshot exist by going into the &#8216;Object Explorer&#8217; and looking under &#8216;Database Shashots&#8217; folder.</p>
<h3>Using T-SQL</h3>
<p>If I use the following T-SQL command to list all my databases:</p>
<pre class="brush: sql; title: ; notranslate">
Select * from [sys].[sysdatabases]
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/02/fix_ListwSysdatabases.png"><img class="aligncenter size-full wp-image-1115" title="fix_ListwSysdatabases" src="http://www.maxtblog.com/wp-content/uploads/2012/02/fix_ListwSysdatabases.png" alt="" width="953" height="379" /></a></p>
<p>I will get all of them listed including the snapshots. So, here&#8217;s another way to use T-SQL to identify all database snapshots. For that, I&#8217;m going to do a select and use from the Master db the view named &#8220;[sys].[databases]&#8220;:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT [name]
      ,[database_id]
      ,[source_database_id]
      ,[owner_sid]
      ,[create_date]
  FROM [master].[sys].[databases]
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/02/fix_TSQL_IdentifyDBSnapshot.png"><img class="aligncenter size-full wp-image-1116" title="fix_TSQL_IdentifyDBSnapshot" src="http://www.maxtblog.com/wp-content/uploads/2012/02/fix_TSQL_IdentifyDBSnapshot.png" alt="" width="926" height="446" /></a></p>
<p>In this result, pay attention to the &#8220;[source_database_id]&#8221; column. Notice that this column is mostly &#8220;null&#8221; except when if it has a value. This value will match the &#8220;[Database_ID]&#8221; column. So, you can use this to identify database snapshots.</p>
<h3>Using PowerShell</h3>
<p>Now, let&#8217;s take a look on how to use PowerShell to identify database snapshots using SMO. In the following code I&#8217;m listing all databases but snapshots are also included.</p>
<pre class="brush: powershell; title: ; notranslate">
Import-Module SQLPS -DisableNameChecking
$MySQL = New-Object Microsoft.SqlServer.management.Smo.Server 'YourServername\InstanceName'
$MySQL.Databases | Select name
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/02/fIX_PS_DBSnapshots_listed1.png"><img class="aligncenter size-full wp-image-1106" title="fIX_PS_DBSnapshots_listed" src="http://www.maxtblog.com/wp-content/uploads/2012/02/fIX_PS_DBSnapshots_listed1.png" alt="" width="1130" height="485" /></a></p>
<p>So, in order to identify the database snapshot I need to look deeper into our .NET database object. Using the &#8220;<strong>Get-Member</strong>&#8221; command I can see what&#8217;s object are available.</p>
<pre class="brush: powershell; title: ; notranslate">
($MySQL.Databases) | Get-Member | Out-Gridview
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/02/PS_GetMember.png"><img class="aligncenter size-full wp-image-1096" title="PS_GetMember" src="http://www.maxtblog.com/wp-content/uploads/2012/02/PS_GetMember.png" alt="" width="790" height="756" /></a></p>
<p>Using the &#8220;<strong>Out-Gridview</strong>&#8221; command to view my results a separate popup window, I found two properties of interest:</p>
<ol>
<li>&#8216;<span style="color: #0000ff;"><em>IsDatabaseSnapshot</em></span>&#8216; &#8211; which show &#8220;<em>true</em>&#8221; us if is a snapshot.</li>
<li>&#8216;<span style="color: #0000ff;"><em>DatabaseSnapshotBaseName</em></span>&#8216; &#8211; which give us the origne of database name of the snapshot.</li>
</ol>
<p>So, now I can use the following PowerShell commands to show all my databases and identify the snapshots:</p>
<pre class="brush: powershell; title: ; notranslate">
$MySQL.Databases | `
   Select name, Owner, RecoveryModel, `
   IsDatabaseSnapshot, DatabaseSnapshotBaseName `
   FT -AutoSize;
</pre>
<p><a href="http://www.maxtblog.com/wp-content/uploads/2012/02/PS_IdentifyDBSnapshot.png"><img class="aligncenter size-full wp-image-1097" title="PS_IdentifyDBSnapshot" src="http://www.maxtblog.com/wp-content/uploads/2012/02/PS_IdentifyDBSnapshot.png" alt="" width="1129" height="501" /></a></p>
<h3>Conclusion</h3>
<p>Using both T-SQL and PowerShell examples, now you have a startup point to spot and take some control over your database snapshots.</p>
<p>Happy PowerShelling!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/02/tsql-powershell-another-way-to-identify-database-snapshots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>“Windows 8 PowerShell and Hyper-V 3.0 Preview” Slide deck and samples</title>
		<link>http://www.maxtblog.com/2012/02/%e2%80%9cwindows-8-powershell-and-hyper-v-3-0-preview%e2%80%9d-slide-deck-and-samples/</link>
		<comments>http://www.maxtblog.com/2012/02/%e2%80%9cwindows-8-powershell-and-hyper-v-3-0-preview%e2%80%9d-slide-deck-and-samples/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 21:01:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Windows 8]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1072</guid>
		<description><![CDATA[Last weekend at the &#8220;ITPro Camp Saturday&#8221; in Sarasota Forida was great event.  Thanks to everyone for participating, and taking the precious time on a Saturday to learn about new and current technologies.  It was a GREAT!! Here&#8217;s my “Windows &#8230; <a href="http://www.maxtblog.com/2012/02/%e2%80%9cwindows-8-powershell-and-hyper-v-3-0-preview%e2%80%9d-slide-deck-and-samples/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last weekend at the &#8220;ITPro Camp Saturday&#8221; in Sarasota Forida was great event.  Thanks to everyone for participating, and taking the precious time on a Saturday to learn about new and current technologies.  It was a GREAT!!</p>
<p>Here&#8217;s my “Windows 8 PowerShell and Hyper-V 3.0 Preview”presentation and demo scripts use during the session:<br />
<iframe title ="Preview" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" width="98px" height="120px" style="padding:0;background-color:#fcfcfc;" src="https://skydrive.live.com/embed?cid=7FD7082276C66197&#038;resid=7FD7082276C66197%21361&#038;authkey=AElDC_taQUtAZwY"></iframe><br />
Please, don&#8217;t hesitate to contact me if you have any questions.</p>
<p>Thanks You!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/02/%e2%80%9cwindows-8-powershell-and-hyper-v-3-0-preview%e2%80%9d-slide-deck-and-samples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It’s Just Random: PowerShell – Mistery of Redrum Solved!!</title>
		<link>http://www.maxtblog.com/2012/02/its-just-random-powershell-mistery-of-reddrum-solved/</link>
		<comments>http://www.maxtblog.com/2012/02/its-just-random-powershell-mistery-of-reddrum-solved/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 20:52:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1066</guid>
		<description><![CDATA[It&#8217;s Friday and I&#8217;m following Jeffery Hicks idea to have fun with PowerShell.  Well, here&#8217;s the mistery of Redrum solved one more time.  Some time ago, I remember seen some code for reversing a string of characters.  Well, here&#8217;s the &#8230; <a href="http://www.maxtblog.com/2012/02/its-just-random-powershell-mistery-of-reddrum-solved/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s Friday and I&#8217;m following Jeffery Hicks idea to have fun with PowerShell.  Well, here&#8217;s the mistery of Redrum solved one more time.  Some time ago, I remember seen some code for reversing a string of characters.  Well, here&#8217;s the one-liner I use to solve the puzzle:</p>
<pre class="brush: powershell; title: ; notranslate">
$str = &quot;Redrum&quot;;
[System.Array]::Reverse(([Array]$RevStr = $str.ToCharArray()));
foreach($chr in $RevStr){ $mistery += $chr }
$mistery;
</pre>
<p>That&#8217;s all for now&#8230;. Have fun with PowerShell!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/02/its-just-random-powershell-mistery-of-reddrum-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuickBlog: PowerShell Automating your Credentials</title>
		<link>http://www.maxtblog.com/2012/02/quickblogpowershell-automating-your-credentials/</link>
		<comments>http://www.maxtblog.com/2012/02/quickblogpowershell-automating-your-credentials/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 20:25:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.maxtblog.com/?p=1060</guid>
		<description><![CDATA[Back in January, I did a quick blog about &#8220;Use PowerShell to submit SQLServicePack job to multiple Server&#8220;, in that script I have PowerShell to always prompt me for credentials.  But, after a while of typing over and over my &#8230; <a href="http://www.maxtblog.com/2012/02/quickblogpowershell-automating-your-credentials/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Back in January, I did a quick blog about &#8220;<a href="http://www.maxtblog.com/2012/01/quickblog-use-powershell-to-submit-sqlservicepack-job-to-multiple-server/" target="_blank">Use PowerShell to submit SQLServicePack job to multiple Server</a>&#8220;, in that script I have PowerShell to always prompt me for credentials.  But, after a while of typing over and over my password, I found to way to automate my credentials.   Yes!  By automating the credential step, I just could schedule the job, and have time to work with something else.</p>
<p>In this example, I&#8217;m passing my credential to the &#8220;<strong>Start-Transfer</strong>&#8221; command, so I can do my file download to my destination folder.  Here&#8217;s the code snippet to accomplish the automation:</p>
<pre class="brush: powershell; title: ; notranslate">
## - Automate to create your credential:
$MyUserName = &quot;Domain\Username&quot;;
$MyPassword =  ConvertTo-SecureString 'MyPwd001!' -asplaintext -force;
$MyCredentials = new-object `
-typename System.Management.Automation.PSCredential `
-argumentlist $MyUserName,$MyPassword;

## - Import the module and start the download process of one file:
Import-Module BitsTransfer;
Start-BitsTransfer `
-Credential $MyCredentials `
-Source 'http://YoufilesSite/Files/Demo01.zip' `
-Destination '\\YourServer\NetworkSharedFolder\Demo01.zip';
</pre>
<p>Ha!  I know what you&#8217;re think!  I&#8217;m hardcoding my password in the scripts.  So, our possible options would be: 1) you&#8217;re the only one running this script (don&#8217;t tell your boss),  2) You trust your Network security (humm!), or 3) find the way to encrypt the script so no one can guess the password.</p>
<p>There are products like SAPIEN&#8217;s PrimalScript and PrimalForms, that will let you create an executable out of your script, and then you can deploy it to your server.  But, then again, only you can make that decision.  I&#8217;m just showing that&#8217;s possible in case you need it.</p>
<p>Have fun with PowerShell!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maxtblog.com/2012/02/quickblogpowershell-automating-your-credentials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

