<?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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>SQLvariations: SQL Server, a little PowerShell, maybe some Hyper-V</title>
	
	<link>http://sqlvariant.com/wordpress</link>
	<description>maybe even the occasional ETL tidbit</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:15:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Sqlvariations" /><feedburner:info uri="sqlvariations" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Sqlvariations</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Atlanta MDF Presents Three Awesome Pre-Cons in Atlanta April 13, 2012</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/9Hx7Ib-2jW8/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2012/02/atlanta-mdf-presents-three-awesome-pre-cons-in-atlanta-april-13-2012/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 20:15:34 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[Training Event]]></category>
		<category><![CDATA[Pre-Cons]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2302</guid>
		<description><![CDATA[Atlanta MDF presents: SQL Saturday #111 Pre-Conference Sessions SQL Saturday is coming back to Atlanta on April 14, and once again, we&#8217;ve managed to schedule 3 awesome pre-con sessions for the Friday before (April 13). They will cover a broad spectrum of topics: Performance Tuning, SSIS, and SSRS. Registration is limited, so go take a look and see if you or someone from your company can benefit from this great training opportunity. Also don&#8217;t forget that we will have an absolutely amazing lineup of presenters for Saturday! We&#8217;ll be announcing the final schedule for SQL Saturday #111 by Monday, February 13th. Registration is open, and we&#8217;re already halfway to capacity, so head out to SQLSaturday.com to reserve your seat. _____________________________________________________________ Andy Leonard and Matt Masson– A Day of SSIS – http://dayofssis.eventbrite.com/ A Day of SSIS was developed by Andy Leonard to train technology professionals in the fine art of using SQL Server Integration Services (SSIS) to build data integration and Extract-Transform-Load (ETL) solutions. The training is focused around lectures and emphasizes a practical approach. The target audience for this training is database professionals, application developers, and business intelligence practitioners interested in acquiring or expanding their existing SSIS skill set. No experience with SQL Server or SQL Server Integration Services is required before attending this training. It is helpful (but not required) that students possess some knowledge of and experience with relational databases. SQL Server knowledge / experience will be more helpful than experience and knowledge with other technologies. _____________________________________________________________ Adam Machanic – No More Guessing! An Enlightened Approach to Performance Troubleshooting – http://nomoreguessing.eventbrite.com/ Scratching your head, you stare at the screen. Should you rebuild an index? Create a new one? Reboot the server? Why is this query so slow?!? Figuring out performance problems can sometimes feel like fumbling your way through a dark room. Maybe you’ll get lucky and find the right solution―or maybe you’ll stub your toe. Either way, it’s a slow, potentially painful process. Yet finding the root cause of most performance issues is a simple exercise, once you understand where to look and when. In this full day seminar, you will learn a proven methodology that can be used to approach virtually any performance problem. Created and refined by Adam Machanic over several years, this strategy leverages core SQL Server performance tools (including dynamic management views, Extended Events, and WMI counters), applying them to various performance troubleshooting techniques (such as waits and queues analysis, baselining, and real-time activity monitoring). Each of these tools and techniques has a unique role, and you will learn to use them cooperatively to quickly and adaptively find the actual cause of performance issues. All of this will be illustrated through complete demonstrations that will teach you how to drill from high-level problem detection all the way to specific spot in a query plan or deeper―pinpointing the exact problem and helping you to quickly solve it. Attend this seminar to take full control of your databases—and never again stumble blindly through the dimly lit world of performance troubleshooting. _____________________________________________________________ Jessica Moss – Learn SSRS in a Day – http://ssrsinaday.eventbrite.com/ SQL Server MVP, Jessica M. Moss, presents an exciting, introductory, full day training session on SQL Server Reporting Services 2008 R2. In the three-part class, Jessica will teach you how to build reports from the ground up. In Part 1, learn the basics of report development, including picking a report development tool and creating your first report. Part 2 delves into visualizations, groupings, and drill-down functionality. Finally, Part 3 highlights core administration tasks in Reporting Services. In addition, Jessica will point out industry-wide best practices for report development and show numerous live demos using a variety of data sources. Friday, April 13, 2012 Georgia State University – Alpharetta 3775 Brookside Pkwy Alpharetta, GA &#160; Register for pre-conference sessions by March 15 for $99! ($109 after March 15) For registration to the Saturday Event and more information visit http://www.sqlsaturday.com/111/eventhome.aspx.]]></description>
			<content:encoded><![CDATA[<h2><strong><a href="http://atlantamdf.com/">Atlanta MDF</a></strong> presents:</h2>
<h2>SQL Saturday #111 Pre-Conference Sessions</h2>
<p><a href="http://www.sqlsaturday.com/111/eventhome.aspx"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://sqlvariant.com/wordpress/wp-content/uploads/2012/02/image.png" width="244" height="126" /></a>SQL Saturday is coming back to Atlanta on April 14, and once again, we&#8217;ve managed to schedule 3 awesome pre-con sessions for the Friday before (April 13). They will cover a broad spectrum of topics: Performance Tuning, SSIS, and SSRS. Registration is limited, so go take a look and see if you or someone from your company can benefit from this great training opportunity.</p>
<p>Also don&#8217;t forget that we will have an absolutely amazing lineup of presenters for Saturday! We&#8217;ll be announcing the final schedule for SQL Saturday #111 by Monday, February 13th. Registration is open, and we&#8217;re already halfway to capacity, so head out to <a href="http://www.sqlsaturday.com/111/eventhome.aspx">SQLSaturday.com</a> to reserve your seat.</p>
<p>_____________________________________________________________</p>
<p><strong>Andy Leonard</strong> and Matt Masson– A Day of SSIS – <a href="http://dayofssis.eventbrite.com/">http://dayofssis.eventbrite.com/</a></p>
<p><a href="http://dayofssis.eventbrite.com/"><img style="display: inline; float: right" alt="" align="right" src="https://evbdn.eventbrite.com/s3-s3/eventlogos/9119273/andytraining-1.jpg" width="200" height="153" /></a>A Day of SSIS was developed by Andy Leonard to train technology professionals in the fine art of using SQL Server Integration Services (SSIS) to build data integration and Extract-Transform-Load (ETL) solutions. The training is focused around lectures and emphasizes a practical approach. The target audience for this training is database professionals, application developers, and business intelligence practitioners interested in acquiring or expanding their existing SSIS skill set. No experience with SQL Server or SQL Server Integration Services is required before attending this training. It is helpful (but not required) that students possess some knowledge of and experience with relational databases. SQL Server knowledge / experience will be more helpful than experience and knowledge with other technologies.</p>
<p>_____________________________________________________________</p>
<p><strong>Adam Machanic</strong> – No More Guessing! An Enlightened Approach to Performance Troubleshooting – <a href="http://nomoreguessing.eventbrite.com/">http://nomoreguessing.eventbrite.com/</a></p>
<p><a href="http://nomoreguessing.eventbrite.com/"><img style="display: inline; float: right" alt="" align="right" src="https://evbdn.eventbrite.com/s3-s3/eventlogos/9119273/adammachanic.jpg" width="146" height="190" /></a>Scratching your head, you stare at the screen. Should you rebuild an index? Create a new one? Reboot the server? Why is this query so slow?!? Figuring out performance problems can sometimes feel like fumbling your way through a dark room. Maybe you’ll get lucky and find the right solution―or maybe you’ll stub your toe. Either way, it’s a slow, potentially painful process. Yet finding the root cause of most performance issues is a simple exercise, once you understand where to look and when. In this full day seminar, you will learn a proven methodology that can be used to approach virtually any performance problem. Created and refined by Adam Machanic over several years, this strategy leverages core SQL Server performance tools (including dynamic management views, Extended Events, and WMI counters), applying them to various performance troubleshooting techniques (such as waits and queues analysis, baselining, and real-time activity monitoring). Each of these tools and techniques has a unique role, and you will learn to use them cooperatively to quickly and adaptively find the actual cause of performance issues. All of this will be illustrated through complete demonstrations that will teach you how to drill from high-level problem detection all the way to specific spot in a query plan or deeper―pinpointing the exact problem and helping you to quickly solve it. Attend this seminar to take full control of your databases—and never again stumble blindly through the dimly lit world of performance troubleshooting.</p>
<p>_____________________________________________________________</p>
<p><strong>Jessica Moss</strong> – Learn SSRS in a Day – <a href="http://ssrsinaday.eventbrite.com/">http://ssrsinaday.eventbrite.com/</a></p>
<p><a href="http://ssrsinaday.eventbrite.com/"><img style="display: inline; float: right" alt="" align="right" src="https://evbdn.eventbrite.com/s3-s3/eventlogos/9119273/jessicamoss.jpg" width="113" height="154" /></a>SQL Server MVP, Jessica M. Moss, presents an exciting, introductory, full day training session on SQL Server Reporting Services 2008 R2. In the three-part class, Jessica will teach you how to build reports from the ground up. In Part 1, learn the basics of report development, including picking a report development tool and creating your first report. Part 2 delves into visualizations, groupings, and drill-down functionality. Finally, Part 3 highlights core administration tasks in Reporting Services. In addition, Jessica will point out industry-wide best practices for report development and show numerous live demos using a variety of data sources.</p>
<p><strong>Friday, April 13, 2012</strong></p>
<p>Georgia State University – Alpharetta   <br />3775 Brookside Pkwy    <br />Alpharetta, GA</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:84E294D0-71C9-4bd0-A0FE-95764E0368D9:1a92bfd7-b6fb-4ecc-ad96-8faaf4bd25dd" class="wlWriterEditableSmartContent"><a href="http://www.bing.com/maps/default.aspx?v=2&amp;cp=34.03531~-84.24385&amp;lvl=12&amp;style=r&amp;sp=aN.34.06126_-84.25098_Georgia%2520State%2520University_&amp;mkt=en-us&amp;FORM=LLWR" id="map-4feba6bc-0cf9-427e-bd1b-6db31b08029c" alt="View map" title="View map"><img src="http://sqlvariant.com/wordpress/wp-content/uploads/2012/02/map-74ef1bef38d4.jpg" width="320" height="240" alt="Map picture"></a></div>
<p>&#160;</p>
<p>Register for pre-conference sessions by<strong> March 15 for $99!     <br /></strong>($109 after March 15)</p>
<p>For registration to the Saturday Event and more information visit <a href="http://www.sqlsaturday.com/111/eventhome.aspx">http://www.sqlsaturday.com/111/eventhome.aspx</a>.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/9Hx7Ib-2jW8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2012/02/atlanta-mdf-presents-three-awesome-pre-cons-in-atlanta-april-13-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2012/02/atlanta-mdf-presents-three-awesome-pre-cons-in-atlanta-april-13-2012/</feedburner:origLink></item>
		<item>
		<title>PowerShell Presentation at SQLskills open-mic night</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/1PJOlxFIGMs/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/12/powershell-presentation-at-sqlskills-open-mic-night/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 15:51:31 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Training Event]]></category>
		<category><![CDATA[Database Sizes]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[SQLskills]]></category>
		<category><![CDATA[Table Sizes]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2294</guid>
		<description><![CDATA[Kimberly Tripp ( blog &#124; twitter ) and Paul Randal ( blog &#124; twitter ) SQLsklls are here in Atlanta this week.  Last night they held an ‘open mic’ night and allowed anyone who wanted to present a topic 15 minutes to show something to the rest of the class.  Surprise, surprise I decided to talk about PowerShell. I received multiple requests to post the scripts I used before I even had a chance to sit down so here they are. If you were in the class and would like to use these and don’t even know where to start with PowerShell have a look at my “Resources for my SQL Server PowerShell Extensions webcast” post. If you ever get a chance to attend one of their classes and present in front of Paul and Kim TAKE IT!   Even if it’s just about your SSMS tips or how to work around a problem you encountered.  The feedback you get is *more* than worth it!]]></description>
			<content:encoded><![CDATA[<p>Kimberly Tripp ( <a href="http://www.sqlskills.com/blogs/Kimberly">blog</a> | <a href="http://twitter.com/#!/KimberlyLTripp">twitter</a> ) and Paul Randal ( <a href="http://www.sqlskills.com/blogs/paul/">blog</a> | <a href="http://twitter.com/#!/PaulRandal">twitter</a> ) <a href="http://www.sqlskills.com/default.asp"><strong>SQLsklls</strong></a> are here in <a href="http://www.sqlskills.com/Atlanta-20111205.asp"><strong>Atlanta this week</strong></a><strong>.</strong>  Last night they held an ‘open mic’ night and allowed anyone who wanted to present a topic 15 minutes to show something to the rest of the class.  Surprise, surprise I decided to talk about PowerShell.</p>
<p>I received multiple requests to post the scripts I used before I even had a chance to sit down so <a href="http://SQLvariant.com/BlogSupport/Scripts/PowerShell/TableSizes_AndCompression.zip"><strong>here they are</strong></a><strong>.</strong></p>
<p>If you were in the class and would like to use these and don’t even know where to start with PowerShell have a look at my “<a href="http://sqlvariant.com/wordpress/index.php/2011/10/resources-for-my-sql-server-powershell-extensions-webcast/"><strong>Resources for my SQL Server PowerShell Extensions webcast</strong></a>” post.</p>
<p>If you ever get a chance to attend one of their classes and present in front of Paul and Kim TAKE IT! <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   Even if it’s just about your SSMS tips or how to work around a problem you encountered.  The feedback you get is *more* than worth it!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/1PJOlxFIGMs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/12/powershell-presentation-at-sqlskills-open-mic-night/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/12/powershell-presentation-at-sqlskills-open-mic-night/</feedburner:origLink></item>
		<item>
		<title>Quick Blog: Grabbing basic machine info with PowerShell</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/tO8dXU3xfKQ/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/11/quick-blog-grabbing-basic-machine-info-with-powershell/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 14:33:00 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[functions]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/11/quick-blog-grabbing-basic-machine-info-with-powershell/</guid>
		<description><![CDATA[The other day I needed to track down how much RAM a couple of our servers had installed.  A few days later I needed to verify that a couple of them were in fact 64-bit and not 32-bit.  I decided I wanted to be able to get at this basic info any time that I wanted without having to remember all the syntax so I built it into a PowerShell function. Building a PowerShell function is almost as easy easier than building a stored procedure around a select statement in SQL.  The reason PowerShell is easier than SQL is that when you have a parameter that you are passing in, you can give it a data type, but you don’t have to. For the function below I gave it a default value of the local machine but you can pass in a machine name that you are trying to get to. Just copy the code below into an ISE window and hit F5. function Get-MachineInfo($ServerName="localhost") { get-wmiobject win32_computersystem -ComputerName $ServerName &#124; select DNSHostName, Manufacturer, Model, SystemType , @{Name="TotalPhysicalMemoryInMB";Expression={"{0:n2}" -f($_.TotalPhysicalMemory/1mb)}}, NumberOfLogicalProcessors, NumberOfProcessors, CurrentTimeZone, DaylightInEffect }# End Get-MachineInfo After you’ve done that, to call the stored proc function simply type in the name ( Get-MachineInfo ) to the prompt at the bottom and hit enter]]></description>
			<content:encoded><![CDATA[<p>The other day I needed to track down how much RAM a couple of our servers had installed.  A few days later I needed to verify that a couple of them were in fact 64-bit and not 32-bit.  I decided I wanted to be able to get at this basic info any time that I wanted without having to remember all the syntax so I built it into a PowerShell function.</p>
<p>Building a PowerShell function is <span style="text-decoration: line-through;">almost as easy</span> easier than building a stored procedure around a select statement in SQL.  The reason PowerShell is easier than SQL is that when you have a parameter that you are passing in, you <strong><em>can</em></strong> give it a data type, but you <span style="text-decoration: underline;">don’t have to</span>.</p>
<p>For the function below I gave it a default value of the local machine but you can pass in a machine name that you are trying to get to.</p>
<p>Just copy the code below into an ISE window and hit F5.</p>
<pre class='PowerShellColorizedScript'><span style='color:#00008b'>function</span> <span style='color:#8a2be2'>Get-MachineInfo</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$ServerName</span><span style='color:#a9a9a9'>=</span><span style='color:#8b0000'>"localhost"</span><span style='color:#000000'>)</span>
<span style='color:#000000'>{</span>
<span style='color:#0000ff'>get-wmiobject</span> <span style='color:#8a2be2'>win32_computersystem</span> <span style='color:#000080'>-ComputerName</span> <span style='color:#ff4500'>$ServerName</span> <span style='color:#a9a9a9'>|</span>
<span style='color:#0000ff'>select</span> <span style='color:#8a2be2'>DNSHostName</span><span style='color:#a9a9a9'>,</span> <span style='color:#8a2be2'>Manufacturer</span><span style='color:#a9a9a9'>,</span> <span style='color:#8a2be2'>Model</span><span style='color:#a9a9a9'>,</span> <span style='color:#8a2be2'>SystemType</span> <span style='color:#a9a9a9'>,</span>
        <span style='color:#000000'>@{</span><span style='color:#000000'>Name</span><span style='color:#a9a9a9'>=</span><span style='color:#8b0000'>"TotalPhysicalMemoryInMB"</span><span style='color:#000000'>;</span><span style='color:#000000'>Expression</span><span style='color:#a9a9a9'>=</span><span style='color:#000000'>{</span><span style='color:#8b0000'>"{0:n2}"</span> <span style='color:#a9a9a9'>-f</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>TotalPhysicalMemory</span><span style='color:#a9a9a9'>/</span><span style='color:#800080'>1mb</span><span style='color:#000000'>)</span><span style='color:#000000'>}</span><span style='color:#000000'>}</span><span style='color:#a9a9a9'>,</span>
        <span style='color:#8a2be2'>NumberOfLogicalProcessors</span><span style='color:#a9a9a9'>,</span> <span style='color:#8a2be2'>NumberOfProcessors</span><span style='color:#a9a9a9'>,</span> <span style='color:#8a2be2'>CurrentTimeZone</span><span style='color:#a9a9a9'>,</span> <span style='color:#8a2be2'>DaylightInEffect</span>
<span style='color:#000000'>}</span><span style='color:#006400'># End Get-MachineInfo</span></pre>
<p>After you’ve done that, to call the <span style="text-decoration: line-through;">stored proc</span> function simply type in the name ( <span style="color: #0000ff; font-family: Segoe UI Semibold; font-size: small;">Get-MachineInfo</span> ) to the prompt at the bottom and hit enter</p>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/11/image2.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/11/image_thumb.png" alt="image" width="473" height="342" border="0" /></a></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/tO8dXU3xfKQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/11/quick-blog-grabbing-basic-machine-info-with-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/11/quick-blog-grabbing-basic-machine-info-with-powershell/</feedburner:origLink></item>
		<item>
		<title>My First MSSQLTip!</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/jNu9ujuzJnY/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/11/my-first-mssqltip/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 02:48:45 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[Denali CTP3]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[MSSQLTip]]></category>
		<category><![CDATA[SQL Server 2012 CTP3]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/11/my-first-mssqltip/</guid>
		<description><![CDATA[Today my first ever MSSQLTip was published.&#160; Before you ask: Yes, it talked about PowerShell. It came about because some of the SQL MVPs were trying to figure out the best way to download a VM that had been split up into 36 different equal-sized files.&#160; I’m sure there’s a better way than this but at the same time it took me about 4 minutes to write.&#160; Write is the wrong term, more like copy/paste/change a few things. Give it a whirl and let me know what you think!&#160;]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mssqltips.com/sqlservertip/2540/simple-way-to-download-sql-denali-ctp3-vm-from-microsoft-using-powershell/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/11/image1.png" width="349" height="113" /></a>Today my <a href="http://www.mssqltips.com/sqlservertip/2540/simple-way-to-download-sql-denali-ctp3-vm-from-microsoft-using-powershell/">first ever MSSQLTip</a> was published.&#160; Before you ask: Yes, it talked about PowerShell.</p>
<p>It came about because some of the SQL MVPs were trying to figure out the best way to download a VM that had been split up into 36 different equal-sized files.&#160; I’m sure there’s a better way than this but at the same time it <strong>took me about 4 minutes to write</strong>.&#160; Write is the wrong term, more like <a href="http://sqlvariant.com/wordpress/index.php/powershell-script-to-download-sql-mcm-videos/">copy</a>/<a href="http://www.microsoft.com/download/en/details.aspx?id=27740">paste</a>/change a few things.</p>
<p>Give it a whirl and let me know what you think!&#160; <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/11/wlEmoticon-smile.png" /></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/jNu9ujuzJnY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/11/my-first-mssqltip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/11/my-first-mssqltip/</feedburner:origLink></item>
		<item>
		<title>Scripts for presentation today at the 2011 PASS Summit</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/u-gfwPV2Bi0/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/10/scripts-for-presentation-today-at-the-2011-pass-summit/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 21:42:12 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PASS Summit]]></category>
		<category><![CDATA[PASS Summit 2011]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/10/scripts-for-presentation-today-at-the-2011-pass-summit/</guid>
		<description><![CDATA[I’m presenting at the PASS Summit today and just wanted to post the scripts I plan on using.  If you’re following along and you’re new to PowerShell I recommend that you have a look at this article I wrote earlier this year: Day Zero with PowerShell Table Size Store Results Compress Tables Compress Indexes Store Results Process Cube Backup Database –PassThru Download Denali CTP Grab Configuration Info New Get-DisksSpace try to pass from Reg servers w/ Group Email Space Report CSV with Bulk Insert Import CSV with Out-DataTable Allen Kinsel – Logs SQL Saturday – Navigate Event Schedule XML]]></description>
			<content:encoded><![CDATA[<p>I’m presenting at the PASS Summit today and just wanted to <a href="http://SQLvariant.com/BlogSupport/Scripts/PowerShell/PASSSummit2011-Dozen.zip"><strong><span style="font-size: x-small;">post the scripts</span></strong></a> I plan on using.  If you’re following along and you’re new to PowerShell I recommend that you have a look at this article I wrote earlier this year: <a href="http://www.sqlservercentral.com/articles/powershell/73288/"><strong><span style="font-size: x-small;">Day Zero with PowerShell </span></strong></a></p>
<ol>
<li>Table Size</li>
<ol>
<li>Store Results</li>
</ol>
<li>Compress Tables</li>
<ol>
<li>Compress Indexes</li>
<li>Store Results</li>
</ol>
<li>Process Cube</li>
<li>Backup Database –PassThru</li>
<li>Download Denali CTP</li>
<li>Grab Configuration Info</li>
<li>New Get-DisksSpace try to pass from Reg servers w/ Group</li>
<li>Email Space Report</li>
<li>CSV with Bulk Insert</li>
<li>Import CSV with Out-DataTable</li>
<li>Allen Kinsel – Logs</li>
<li>SQL Saturday – Navigate Event Schedule XML</li>
</ol>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/u-gfwPV2Bi0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/10/scripts-for-presentation-today-at-the-2011-pass-summit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/10/scripts-for-presentation-today-at-the-2011-pass-summit/</feedburner:origLink></item>
		<item>
		<title>Whats in my PowerShell Profile</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/J8a8hklBrVU/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/10/whats-in-my-powershell-profile/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 20:08:17 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PASS Summit]]></category>
		<category><![CDATA[PASS Summit 2011]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/10/whats-in-my-powershell-profile/</guid>
		<description><![CDATA[Here are two zip files.  The first file is my profile and the second zip file is the scripts that my profiles references.  These are just some of the tools I find useful for enhancing PowerShell.]]></description>
			<content:encoded><![CDATA[<p>Here are two zip files.  The first file is <a href="http://sqlvariant.com/BlogSupport/Scripts/PowerShell/BasicProfile.zip">my profile</a> and the <a href="http://SQLvariant.com/BlogSupport/Scripts/PowerShell/ScriptsInMyProfile.zip">second zip file</a> is the scripts that my profiles references.  These are just some of the tools I find useful for enhancing PowerShell.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/J8a8hklBrVU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/10/whats-in-my-powershell-profile/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/10/whats-in-my-powershell-profile/</feedburner:origLink></item>
		<item>
		<title>Resources for my SQL Server PowerShell Extensions webcast</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/JaRcLX0cyiI/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/10/resources-for-my-sql-server-powershell-extensions-webcast/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 21:03:05 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[Denali CTP3]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQLPSX]]></category>
		<category><![CDATA[Webcast]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/10/resources-for-my-sql-server-powershell-extensions-webcast/</guid>
		<description><![CDATA[I did another webcast for the Secrets of SQL Server webcast series today.  In the today’s webcast we built on some things I had demoed in a prior webcast and showed how PowerShell in conjunction with SQLPSX can really help you solve some common problems DBAs face. I showed how you could pull size and free space information from all of your data files, then used the same technique to pull size information from all of your tables across every database on an instance.  Later we created a database and some tables, and then showed how to do some basic login comparisons, all with SQLPSX. In addition, we stored the results of the frees pace and table size information in a database using the Out-DataTable and Write-DataTable functions.  Finally we wrapped up with a quick demo on how the new SQL Server cmdlets inside of the SQLPS Module in Denali combined with some new functionality in PowerShell v3 CTP1 can really make backing up a database with PowerShell a lot easier. Here’s what you’ll need to recreate today’s demos; Download and install SQLPSX The Out-DataTable function from the TechNet script repository The Write-DataTable function from the TechNet script repository and these scripts Oh, and here are the handful of slides that I had I hope I see you next week at the PASS Summit or next month during another webcast, this time on customizing your own functions to work with the SMO.]]></description>
			<content:encoded><![CDATA[<p><a href="http://a1100.v46030f.c46030.g.vm.akamaistream.net/7/1100/46030/v0001/smb2.download.akamai.com/46030/Idera/100511-SQLSP01/100511-SQLSP01_archive.wmv"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/10/image_thumb.png" alt="image" width="220" height="244" align="right" border="0" /></a>I did another<strong> <a href="http://a1100.v46030f.c46030.g.vm.akamaistream.net/7/1100/46030/v0001/smb2.download.akamai.com/46030/Idera/100511-SQLSP01/100511-SQLSP01_archive.wmv">webcast </a></strong>for the <a href="http://www.idera.com/Education/SQL-server-Webcasts/">Secrets of SQL Server</a> webcast series today.  In the today’s webcast we built on some things I had demoed in a <a href="http://www.idera.com/Events/RegisterWC.aspx?EventID=232">prior webcast</a> and showed how PowerShell in conjunction with <strong><a href="http://sqlpsx.codeplex.com/">SQLPSX</a></strong> can really help you solve some common problems DBAs face.</p>
<p>I showed how you could pull size and free space information from all of your data files, then used the same technique to pull size information from all of your tables across every database on an instance.  Later we created a database and some tables, and then showed how to do some basic login comparisons, all with SQLPSX.</p>
<p>In addition, we stored the results of the frees pace and table size information in a database using the Out-DataTable and Write-DataTable functions.  Finally we wrapped up with a quick demo on how the new SQL Server cmdlets inside of the SQLPS Module in Denali combined with some new functionality in PowerShell v3 CTP1 can really make backing up a database with PowerShell a lot easier.</p>
<p>Here’s what you’ll need to recreate today’s demos;</p>
<ul>
<li>Download and install <a href="http://sqlpsx.codeplex.com/"><strong>SQLPSX</strong></a></li>
<li>The <a href="http://gallery.technet.microsoft.com/scriptcenter/4208a159-a52e-4b99-83d4-8048468d29dd"><strong>Out-DataTable</strong></a> function from the TechNet script repository</li>
<li>The <strong><a href="http://gallery.technet.microsoft.com/scriptcenter/2fdeaf8d-b164-411c-9483-99413d6053ae">Write-DataTable</a></strong> function from the TechNet script repository</li>
<li>and <strong><a href="http://SQLvariant.com/BlogSupport/Scripts/PowerShell/SoSS_Webcast2.zip">these scripts</a></strong></li>
<li>Oh, and here are the handful of <a href="http://SQLvariant.com/BlogSupport/SlideDecks/SoSS-GetMoreDoneWithSQLPSX.pptx">slides</a> that I had</li>
</ul>
<p>I hope I see you next week at the PASS Summit or next month during another webcast, this time on customizing your own functions to work with the SMO.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/JaRcLX0cyiI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/10/resources-for-my-sql-server-powershell-extensions-webcast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://a1100.v46030f.c46030.g.vm.akamaistream.net/7/1100/46030/v0001/smb2.download.akamai.com/46030/Idera/100511-SQLSP01/100511-SQLSP01_archive.wmv" length="0" type="video/asf" />
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/10/resources-for-my-sql-server-powershell-extensions-webcast/</feedburner:origLink></item>
		<item>
		<title>And We’re Back!</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/q8ukVnkmbjU/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/09/and-were-back/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 12:53:23 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/09/and-were-back/</guid>
		<description><![CDATA[This page has been intentionally left blank for most of the last 4 months while I get some higher priority items taken care of. The hole in my theory about taking a break from blogging and being on twitter was that hundreds of people still have questions about PowerShell and my email address. I plan to post the answers to those questions over the next several weeks. In the meantime I want to give a quick mention about SQL Saturday #89 happening here in Atlanta in just 12 days. We’ve hit the maximum number of registrations we feel comfortable handling. If you’re on the wait list, we’ll send out an email later this week to people that were able to successfully register but now can’t make it, asking them to unregister. From the looks of the registration counts this might end up being a little under twice the size of last year’s SQL Saturday. More blogs coming soon!]]></description>
			<content:encoded><![CDATA[<p>This page has been intentionally left blank for most of the last 4 months while I get some higher priority items taken care of. The hole in my theory about taking a break from blogging and being on twitter was that hundreds of people still have questions about PowerShell and my email address. I plan to post the answers to those questions over the next several weeks.</p>
<p>In the meantime I want to give a quick mention about <a href="http://www.sqlsaturday.com/89/eventhome.aspx">SQL Saturday #89</a> happening here in Atlanta in just 12 days. We’ve hit the maximum number of registrations we feel comfortable handling. If you’re on the wait list, we’ll send out an email later this week to people that were able to successfully register but now can’t make it, asking them to unregister. From the looks of the registration counts this might end up being a little under twice the size of last year’s SQL Saturday.</p>
<p>More blogs coming soon!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/q8ukVnkmbjU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/09/and-were-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/09/and-were-back/</feedburner:origLink></item>
		<item>
		<title>New PowerShell Cmdlets in SQL Denali CTP3</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/MVJ9LcG-OAQ/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/07/new-powershell-cmdlets-in-sql-denali-ctp3/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 13:38:27 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Denali]]></category>
		<category><![CDATA[IntegrationServices]]></category>
		<category><![CDATA[SQLAS]]></category>
		<category><![CDATA[XEvent]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2243</guid>
		<description><![CDATA[CTP3 of SQL Denali is finally publicly available! I woke up at 5 am this morning to kick off my download.  I&#8217;ve finished the install and I&#8217;m happy that I can finally report that we have new cmdlets for SQL Server.  First off, after running Get-Module -ListAvailable I saw: Manifest   SQLASCMDLETS Manifest   SQLPS This means that SQLPS inside of SQL Agent should finally allow you to import a module during your job step.  There is now a Function called SQLServer that, from what I can tell, is the SQLServer Provider.  When under PS SQLSERVER:\&#62; if you do a dir &#124; Select pschildname you will find the following list: PSChildName &#8212;&#8212;&#8212;&#8211; SQL SQLPolicy SQLRegistration DataCollection XEvent Utility DAC IntegrationServices SQLAS From my notes it looks like XEvent, IntegrationServices, and SQLAS are the directories that have been added here.  Can&#8217;t wait to try out the IntegrationServices portion!  [Update]: Apparently I may need a defaul instance install for this to work. I also noticed that Tab-Completion appears to be fixed!!    Also, SQL Registrations &#62; &#8216;Database Engine Server Group&#8217; are split up into instances like CMS was.  Not sure what that&#8217;s all about just yet.  In fact when I try to use it, it doesn&#8217;t seem to work.  Maybe I should read the help files.  But I think they may have just gotten CMS &#38; RS reversed.  CMS isn&#8217;t working for me either yet. When you drill down under XEvents and go to your Denali instaince you will see: Packages, &#38; Sessions.  I guess this means that I finally need to read Jonathat&#8217;s blog series on X-Events. When I imported the SQLPS module I received a warning about unapproved verbs.  Oh well, hopefully they&#8217;ll work that out soon.  Next I ran Get-Command -Module &#8220;SQLPS&#8221; and found the following list of cmdlets. Name Module Add-SqlAvailabilityDatabase SQLPS Add-SqlAvailabilityGroupListenerStaticIp SQLPS Backup-SqlDatabase SQLPS Convert-UrnToPath SQLPS Decode-SqlName SQLPS Disable-SqlHADRService SQLPS Enable-SqlHADRService SQLPS Encode-SqlName SQLPS Invoke-PolicyEvaluation SQLPS Invoke-Sqlcmd SQLPS Join-SqlAvailabilityGroup SQLPS New-SqlAvailabilityGroup SQLPS New-SqlAvailabilityGroupListener SQLPS New-SqlAvailabilityReplica SQLPS New-SqlHADREndpoint SQLPS Remove-SqlAvailabilityDatabase SQLPS Remove-SqlAvailabilityGroup SQLPS Remove-SqlAvailabilityReplica SQLPS Restore-SqlDatabase SQLPS Resume-SqlAvailabilityDatabase SQLPS Set-SqlAvailabilityGroup SQLPS Set-SqlAvailabilityGroupListener SQLPS Set-SqlAvailabilityReplica SQLPS Set-SqlHADREndpoint SQLPS SQLSERVER SQLPS Suspend-SqlAvailabilityDatabase SQLPS Switch-SqlAvailabilityGroup SQLPS Test-SqlAvailabilityGroup SQLPS Test-SqlAvailabilityReplica SQLPS Test-SqlDatabaseReplicaState SQLPS Analysis Services got some love too in the form of 11 cmdlets!  After inporting the SQLASCMDLETS module I ran this Get-Command -Module &#8220;SQLASCMDLETS&#8221; and found the following. Name Module Add-RoleMember SQLASCMDLETS Backup-ASDatabase SQLASCMDLETS Invoke-ASCmd SQLASCMDLETS Invoke-ProcessCube SQLASCMDLETS Invoke-ProcessDimension SQLASCMDLETS Invoke-ProcessPartition SQLASCMDLETS Merge-Partition SQLASCMDLETS New-RestoreFolder SQLASCMDLETS New-RestoreLocation SQLASCMDLETS Remove-RoleMember SQLASCMDLETS Restore-ASDatabase SQLASCMDLETS More news to follow soon!]]></description>
			<content:encoded><![CDATA[<p>CTP3 of SQL Denali is finally <a href="https://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/default.aspx" target="_blank">publicly available</a>!</p>
<p>I woke up at 5 am this morning to kick off my download.  I&#8217;ve finished the install and I&#8217;m happy that I can finally report that we have new cmdlets for SQL Server. </p>
<p>First off, after running <span style="color: #0000ff;">Get-Module</span> <span style="color: #000080;">-ListAvailable</span> I saw:</p>
<p>Manifest   SQLASCMDLETS<br />
Manifest   SQLPS</p>
<p>This means that SQLPS inside of SQL Agent should finally allow you to import a module during your job step. </p>
<p>There is now a Function called SQLServer that, from what I can tell, is the SQLServer Provider.  When under PS SQLSERVER:\&gt; if you do a <span style="color: #0000ff;">dir</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Select</span> <span style="color: #8a2be2;">pschildname</span> you will find the following list:</p>
<p>PSChildName<br />
&#8212;&#8212;&#8212;&#8211;<br />
SQL<br />
SQLPolicy<br />
SQLRegistration<br />
DataCollection<br />
<strong>XEvent</strong><br />
Utility<br />
DAC<br />
<strong>IntegrationServices</strong><br />
<strong>SQLAS</strong></p>
<p>From my notes it looks like <strong><span style="color: #003366;">XEvent</span></strong>, <strong><span style="color: #003366;">IntegrationServices</span></strong>, and <strong><span style="color: #003366;">SQLAS </span></strong>are the directories that have been added here.  Can&#8217;t wait to try out the IntegrationServices portion!  [Update]: Apparently I may need a defaul instance install for this to work.</p>
<p>I also noticed that <span style="color: #003300;"><strong>Tab-Completion </strong></span>appears to be fixed!!  <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   Also, SQL Registrations &gt; &#8216;Database Engine Server Group&#8217; are split up into instances like CMS was.  Not sure what that&#8217;s all about just yet.  In fact when I try to use it, it doesn&#8217;t seem to work.  Maybe I should read the help files.  But I think they may have just gotten CMS &amp; RS reversed.  CMS isn&#8217;t working for me either yet.</p>
<p>When you drill down under XEvents and go to your Denali instaince you will see: Packages, &amp; Sessions.  I guess this means that I finally need to read Jonathat&#8217;s blog series on X-Events.</p>
<p>When I imported the SQLPS module I received a warning about unapproved verbs.  Oh well, hopefully they&#8217;ll work that out soon.  Next I ran <strong><span style="color: #0000ff;">Get-Command</span> <span style="color: #000080;">-Module</span> <span style="color: #8b0000;">&#8220;SQLPS&#8221;</span></strong> and found the following list of cmdlets.</p>
<table border="0" cellspacing="0" cellpadding="0" width="370">
<colgroup span="1">
<col span="1" width="267"></col>
<col span="1" width="103"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="267" height="20">Name</td>
<td width="103">Module</td>
</tr>
<tr height="20">
<td height="20">Add-SqlAvailabilityDatabase</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Add-SqlAvailabilityGroupListenerStaticIp</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Backup-SqlDatabase</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Convert-UrnToPath</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Decode-SqlName</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Disable-SqlHADRService</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Enable-SqlHADRService</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Encode-SqlName</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Invoke-PolicyEvaluation</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Invoke-Sqlcmd</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Join-SqlAvailabilityGroup</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">New-SqlAvailabilityGroup</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">New-SqlAvailabilityGroupListener</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">New-SqlAvailabilityReplica</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">New-SqlHADREndpoint</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Remove-SqlAvailabilityDatabase</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Remove-SqlAvailabilityGroup</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Remove-SqlAvailabilityReplica</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Restore-SqlDatabase</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Resume-SqlAvailabilityDatabase</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Set-SqlAvailabilityGroup</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Set-SqlAvailabilityGroupListener</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Set-SqlAvailabilityReplica</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Set-SqlHADREndpoint</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">SQLSERVER</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Suspend-SqlAvailabilityDatabase</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Switch-SqlAvailabilityGroup</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Test-SqlAvailabilityGroup</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Test-SqlAvailabilityReplica</td>
<td>SQLPS</td>
</tr>
<tr height="20">
<td height="20">Test-SqlDatabaseReplicaState</td>
<td>SQLPS</td>
</tr>
</tbody>
</table>
<p>Analysis Services got some love too in the form of 11 cmdlets!  After inporting the SQLASCMDLETS module I ran this <span style="color: #0000ff;">Get-Command</span> <span style="color: #000080;">-Module</span> <span style="color: #8b0000;">&#8220;SQLASCMDLETS&#8221;</span> and found the following.</p>
<table border="0" cellspacing="0" cellpadding="0" width="370">
<colgroup span="1">
<col span="1" width="267"></col>
<col span="1" width="103"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="267" height="20">Name</td>
<td width="103">Module</td>
</tr>
<tr height="20">
<td height="20">Add-RoleMember</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Backup-ASDatabase</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Invoke-ASCmd</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Invoke-ProcessCube</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Invoke-ProcessDimension</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Invoke-ProcessPartition</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Merge-Partition</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">New-RestoreFolder</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">New-RestoreLocation</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Remove-RoleMember</td>
<td>SQLASCMDLETS</td>
</tr>
<tr height="20">
<td height="20">Restore-ASDatabase</td>
<td>SQLASCMDLETS</td>
</tr>
</tbody>
</table>
<p>More news to follow soon!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/MVJ9LcG-OAQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/07/new-powershell-cmdlets-in-sql-denali-ctp3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/07/new-powershell-cmdlets-in-sql-denali-ctp3/</feedburner:origLink></item>
		<item>
		<title>PowerShell takes the Pole at SQLRally!</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/8pXVOjdwkDM/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/05/powershell-takes-the-pole-at-sqlrally/#comments</comments>
		<pubDate>Tue, 10 May 2011 13:26:02 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Training Event]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[SQLRally]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2234</guid>
		<description><![CDATA[PowerShell takes the Pole at SQLRally! PowerShell has taken the Pole for the DBA division at SQLRally!  Come see why the organizers have chosen this session to lead the pack to the Green Flag. We will be covering new ground, not rehashing last year’s PASS Summit presentation.  I have developed several new examples for leveraging PowerShell in your everyday DBA role since then.  I am promising 6 new scripts for everyone but if I get on a role that number might be closer to 10 when they drop the green flag on this year’s event.  If you’ve never used PowerShell before don’t worry. We will spend a few minutes on a ‘get up to speed lap’ so everyone is going at the same pace when we step on the gas with all this new material.  All scripts will be made available for you to download during the session and access later on from pit-row. After my session here’s what I’ll be checking out:  ]]></description>
			<content:encoded><![CDATA[<h1><span style="font-size: large;"><span style="color: #365f91;"><span style="font-family: Cambria;">PowerShell takes the Pole at SQLRally!</span></span></span></h1>
<p><span style="font-size: small;"><span style="font-family: Calibri;">PowerShell has taken the Pole for the DBA division at SQLRally!  Come see why the organizers have chosen this session to lead the pack to the Green Flag.</span></span></p>
<p><span style="font-family: Calibri; font-size: small;">We <strong><span style="text-decoration: underline;">will be covering new ground</span></strong>, not rehashing last year’s </span><a href="http://sqlpass.eventpoint.com/topic/details/DBA237"><span style="font-family: Calibri; color: #0000ff; font-size: small;">PASS Summit</span></a><span style="font-size: small;"><span style="font-family: Calibri;"> presentation.  I have developed several new examples for leveraging PowerShell in your everyday DBA role since then.  I am promising 6 new scripts for everyone but if I get on a role that number might be closer to 10 when they drop the green flag on this year’s event.  <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">If you’ve never used PowerShell before don’t worry. We will spend a few minutes on a ‘get up to speed lap’ so everyone is going at the same pace when we step on the gas with all this new material.  All scripts will be made available for you to download during the session and access later on from pit-row. </span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">After my session here’s what I’ll be checking out:</span></span></p>
<p><span style="font-size: small;"> </span></p>
<div id="attachment_2235" class="wp-caption aligncenter" style="width: 656px"><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/05/My_SQLRally_Schedule.jpg"><img class="size-full wp-image-2235" title="My_SQLRally_Schedule" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/05/My_SQLRally_Schedule.jpg" alt="What sessions I'll be checking out during SQLRally" width="646" height="871" /></a><p class="wp-caption-text">What sessions I&#39;ll be checking out during SQLRally</p></div>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/8pXVOjdwkDM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/05/powershell-takes-the-pole-at-sqlrally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/05/powershell-takes-the-pole-at-sqlrally/</feedburner:origLink></item>
		<item>
		<title>PowerShell Week at SQL University – Post 7</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/jZzRXVOwqsg/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/04/powershell-week-at-sql-university-post-7/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 13:28:37 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL University]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2222</guid>
		<description><![CDATA[Deploying Code Deploying SQL code with PowerShell can be very easy but why would you want to do that instead of just open a script in SQL Management Studio and run it?  The number 1 reason that I can think of is when you need to deploy to multiple destinations.  Let’s get started with something simple, we’ll deploy a table that I use in the post on collecting database sizes. Invoke-Sqlcmd -ServerInstance Win7Netbook -Database CentralInfo -InputFile C:\temp\dbo.DatabaseFileSizes.SQL That’s a pretty simple example and one that doesn’t offer too much any benefit over just opening up SSMS and running the script.   Let’s take it a little further with the loop construct and this time we’ll deploy Adam Machanic’s ( blog &#124; twitter ) sp_WhoIsActive to a bunch of machines $DeployFile = C:\temp\who_is_active_v11_00.sql &#60;# Loops through Registered SQL Severs and applys WhoIsActive #&#62; foreach ($RegisteredSQLs in dir -recurse SQLSERVER:\SQLRegistration\'Database Engine Server Group'\Development\ &#124; where {$_.Mode -ne "d"} ) { "Deploying to "+ $RegisteredSQLs.ServerName; Invoke-Sqlcmd -InputFile $DeployFile -ServerInstance $RegisteredSQLs.ServerName -database master} So now we can see how we can deploy a SQL Script to multiple machines with just 4 lines of PowerShell.  The script obviously doesn’t have to be deploying code.  It could inserting/updating data or even verifying permissions.]]></description>
			<content:encoded><![CDATA[<p>Deploying Code</p>
<p>Deploying SQL code with PowerShell can be very easy but why would you want to do that instead of just open a script in SQL Management Studio and run it?  The number 1 reason that I can think of is when you need to deploy to multiple destinations.  Let’s get started with something simple, we’ll deploy a table that I use in the post on collecting database sizes.</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 51px;"><span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8a2be2;">Win7Netbook</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">CentralInfo</span> <span style="color: #000080;">-InputFile</span> <span style="color: #8a2be2;">C:\temp\dbo.DatabaseFileSizes.SQL</span></pre>
<p>That’s a pretty simple example and one that doesn’t offer <span style="text-decoration: line-through;">too much</span> any benefit over just opening up SSMS and running the script.   Let’s take it a little further with the loop construct and this time we’ll deploy Adam Machanic’s ( <a href="http://sqlblog.com/blogs/adam_machanic/default.aspx">blog</a> | <a href="http://twitter.com/AdamMachanic">twitter</a> ) <a href="http://sqlblog.com/blogs/adam_machanic/archive/2010/11/23/who-is-active-wins-gold-from-sql-server-magazine.aspx">sp_WhoIsActive</a> to a bunch of machines</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 163px;"><span style="color: #ff4500;">$DeployFile</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">C:\temp\who_is_active_v11_00.sql</span>
<span style="color: #006400;">&lt;# Loops through Registered SQL Severs and applys WhoIsActive #&gt;</span>
<span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$RegisteredSQLs</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #000080;">-recurse</span> <span style="color: #8a2be2;">SQLSERVER:\SQLRegistration\'Database Engine Server Group'\Development\</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Mode</span> <span style="color: #a9a9a9;">-ne</span> <span style="color: #8b0000;">"d"</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #8b0000;">"Deploying to "</span><span style="color: #a9a9a9;">+</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span><span style="color: #000000;">;</span>
<span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-InputFile</span> <span style="color: #ff4500;">$DeployFile</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span><span style="color: #000000;">}</span></pre>
<p>So now we can see how we can deploy a SQL Script to multiple machines with just 4 lines of PowerShell.  The script obviously doesn’t have to be deploying code.  It could inserting/updating data or even verifying permissions.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/jZzRXVOwqsg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/04/powershell-week-at-sql-university-post-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/04/powershell-week-at-sql-university-post-7/</feedburner:origLink></item>
		<item>
		<title>Late April Free Training from PASS VCs</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/wFTYqCDSExY/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/04/late-april-pass-vc-presentations/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 14:30:22 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[BI]]></category>
		<category><![CDATA[Free Training]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2213</guid>
		<description><![CDATA[PowerShell provisioning of Hyper-V Servers Designing Cubes for Performance Database Standards SOP _____________________________________________________________ PowerShell provisioning of Hyper-V Servers April 20, 2011, 12 PM EDT (GMT -4) Marco Shaw Marco provides an overview of using sysprep for Windows Server 2008R2, and SQL Server 2008R2, which also now supports this feature. This is especially useful when wanting to get up a new (lab or even production environment) quickly. He will be doing this using only Microsoft Hyper-V &#38; Windows PowerShell without any other external tools. Marco Shaw Marco ( blog &#124; twitter ) is a consultant with CGI and has over 12 years of IT experience. He has been awarded a Microsoft MVP award for the last 4 years in the Windows PowerShell category. LiveMeeting: Registration Link _____________________________________________________________ Designing Cubes for Performance April 20, 2011, 12 PM EDT (GMT -4) Stacia Misner Building a cube is simple. After all, you have a lot of wizards at your disposal to do the development work. But building a cube that delivers data quickly requires you to make additional changes to the database design. In this session, you’ll learn what steps you need to take in the development process to ensure the cube is designed for optimal performance, whether you’re using Analysis Services 2005 or Analysis Services 2008. You learn not only how to properly design dimensions, aggregates, and partitions, but why these design principles improve performance. Bio: Stacia Misner is a consultant, educator, mentor, and author specializing in Business Intelligence solutions since 1999. With more than 25 years of experience in IT, she is the author or co-author of ten books about BI. Her most recent books include Business Intelligence in Microsoft SharePoint 2010 and Building Integrated Business Intelligence Solutions with SQL Server 2008 R2 and Office 2010. Stacia provides consulting and custom education services through Data Inspirations, writes about her experiences with BI at blog.datainspirations.com, and tweets as @StaciaMisner. LiveMeeting: Link _____________________________________________________________ Database Standards SOP April 21, 2011, 1 PM EDT (GMT -4) Thomas LeBlanc Join Normalization nut Thomas LeBlanc for a review of a standard operating procedure used among DBAs at an employer. See the changes he made after joining the BI group at this employer. The session will go through naming conventions, check list for creating a table, formatting in stored procedures, and more. A brief preview of the SQLRally talk 3rd Normal Form: That’s Crazy Talk!!! Will be given about Lookup tables. This discussion comes from 21+ years of developing databases for application developers. The use of identity columns for primary keys, and the need for a unique constraint on transaction tables that do resort to ID columns will be covered. Thomas LeBlanc Thomas is a semi-retired Senior DBA turned ETL Lead Architect @ Amedisys in Baton Rouge, LA. Worked in the IT field for 21 years experience w/ COBOL dBase, FoxPro, Visual FoxPro, VB 3 thru 6 and .Net(C#). Designing and developing Normalized &#38; Dimensional database has become his passion. Full-time DBA work started about 9 years ago. he has been blessed with speaking at SQLRally this year. Free time is spent helping other &#38; improving his relationship with family &#38; God. LiveMeeting: Link]]></description>
			<content:encoded><![CDATA[<p><a href="http://appdev.sqlpass.org/"><img style="display: inline; float: right;" src="http://www.sqlpass.org/Portals/_default/Skins/pass_skins_fixed_smallbanner/pass_logo.gif" alt="www.sqlpass.org" align="right" /></a><strong>PowerShell provisioning of Hyper-V Servers</strong><br />
<strong>Designing Cubes for Performance</strong><br />
<strong>Database Standards SOP</strong><br />
_____________________________________________________________<br />
<strong>PowerShell provisioning of Hyper-V Servers</strong><br />
<strong>April 20, 2011, 12 PM EDT (GMT -4)</strong><br />
<strong>Marco Shaw</strong></p>
<p>Marco provides an overview of using sysprep for Windows Server 2008R2, and SQL Server 2008R2, which also now supports this feature. This is especially useful when wanting to get up a new (lab or even production environment) quickly. He will be doing this using only Microsoft Hyper-V &amp; Windows PowerShell without any other external tools.</p>
<p><strong>Marco Shaw</strong><strong> </strong><br />
Marco ( <a href="http://marcoshaw.blogspot.com/">blog</a> | <a href="http://twitter.com/MarcoShaw">twitter</a> ) is a consultant with CGI and has over 12 years of IT experience. He has been awarded a Microsoft MVP award for the last 4 years in the Windows PowerShell category.</p>
<p><strong>LiveMeeting: </strong><a href="https://www.livemeeting.com/lrs/8000181573/Registration.aspx?pageName=6hz3d56pc029v7l7"><strong>Registration Link</strong></a><br />
_____________________________________________________________<br />
<strong>Designing Cubes for Performance</strong><br />
<strong>April 20, 2011, 12 PM EDT (GMT -4)</strong><br />
<strong>Stacia Misner</strong></p>
<p>Building a cube is simple. After all, you have a lot of wizards at your disposal to do the development work. But building a cube that delivers data quickly requires you to make additional changes to the database design. In this session, you’ll learn what steps you need to take in the development process to ensure the cube is designed for optimal performance, whether you’re using Analysis Services 2005 or Analysis Services 2008. You learn not only how to properly design dimensions, aggregates, and partitions, but why these design principles improve performance.</p>
<p><strong>Bio:</strong><br />
Stacia Misner is a consultant, educator, mentor, and author specializing in Business Intelligence solutions since 1999. With more than 25 years of experience in IT, she is the author or co-author of ten books about BI. Her most recent books include Business Intelligence in Microsoft SharePoint 2010 and Building Integrated Business Intelligence Solutions with SQL Server 2008 R2 and Office 2010. Stacia provides consulting and custom education services through Data Inspirations, writes about her experiences with BI at <a href="http://blog.datainspirations.com/">blog.datainspirations.com</a>, and tweets as <a href="http://twitter.com/StaciaMisner">@StaciaMisner</a>.</p>
<p><strong>LiveMeeting:</strong> <strong><a href="https://www.livemeeting.com/cc/usergroups/join?id=FCK6BC&amp;role=attend&amp;pw=49%3Esn%3DDfs">Link</a></strong><br />
_____________________________________________________________<br />
<strong>Database Standards SOP</strong><br />
<strong>April 21, 2011, 1 PM EDT (GMT -4)</strong><br />
<strong>Thomas LeBlanc</strong></p>
<p>Join Normalization nut Thomas LeBlanc for a review of a standard operating procedure used among DBAs at an employer. See the changes he made after joining the BI group at this employer. The session will go through naming conventions, check list for creating a table, formatting in stored procedures, and more. A brief preview of the SQLRally talk 3rd Normal Form: That’s Crazy Talk!!! Will be given about Lookup tables. This discussion comes from 21+ years of developing databases for application developers. The use of identity columns for primary keys, and the need for a unique constraint on transaction tables that do resort to ID columns will be covered.</p>
<p><strong>Thomas LeBlanc</strong><br />
Thomas is a semi-retired Senior DBA turned ETL Lead Architect @ Amedisys in Baton Rouge, LA. Worked in the IT field for 21 years experience w/ COBOL dBase, FoxPro, Visual FoxPro, VB 3 thru 6 and .Net(C#). Designing and developing Normalized &amp; Dimensional database has become his passion. Full-time DBA work started about 9 years ago. he has been blessed with speaking at SQLRally this year. Free time is spent helping other &amp; improving his relationship with family &amp; God.</p>
<p><strong>LiveMeeting: </strong><a href="https://www.livemeeting.com/cc/usergroups/join?id=28NR92&amp;role=attend&amp;pw=PTSs%26%5E%282Z"><strong>Link</strong></a><strong> </strong></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/wFTYqCDSExY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/04/late-april-pass-vc-presentations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/04/late-april-pass-vc-presentations/</feedburner:origLink></item>
		<item>
		<title>Mid April Free Training from PASS VCs</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/LDRlpbOjwao/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/04/mid-april-free-training-from-pass-vcs/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 22:53:15 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[AppDev]]></category>
		<category><![CDATA[BI]]></category>
		<category><![CDATA[Free Training]]></category>
		<category><![CDATA[PASS]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2206</guid>
		<description><![CDATA[Building Applications That A DBA Will Love All About Analysis Services _____________________________________________________________ Building Applications That A DBA Will Love April 12, 2011, 12 PM Eastern Presenter: Andy Warren Attendee URL: LiveMeeting It’s natural for the focus to be on the end user when we build applications, but it’s important and worthwhile to build into our design some things that make it easier for the DBA to provision, tune, and support the product we deliver. So what does a DBA care about? Performance of course, but also security, scalability, space usage, and yes, even documentation. This presentation will cover tips in a number of areas that address the concerns of the DBA, and we’ll talk about why you should care about making the DBA happy too! Andy Warren Andy Warren is a SQL Server consultant and trainer who occasionally writes some code too. He’s on the PASS Board of Directors, was a founding partner in SQLServerCentral.com, started the SQLSaturday event format, and is currently a SQL Server MVP. Andy blogs at www.sqlandy.com, and can be reached via Twitter as @sqlandy and on LinkedIn at www.linkedin.com/in/sqlandy. How do I attend? Attendee URL: LiveMeeting _____________________________________________________________ Efficient and effective processing of OLAP CUBES with AMO and XMLA Fri April 15th 12PM EST (US) Speaker: Steve Simon Topic Description: Within the financial industry, rapid and effective decision making is critical to our client relationships. Analytical tools such as OLAP cubes help make this a reality. In many 24 X 7 enterprises, data capture and cube updates occur on an ongoing basis throughout the business day. We are able to achieve this through the innovative utilization of SQL Server Integration Services (SSIS). This intermediate level hands-on presentation will show the attendee how we have utilized Analysis Management Objects (AMO) commands and SSIS to ‘fire’ our OLAP CUBE updating processes. The presentation will discuss the high level concepts behind Analysis Management Objects (and the XMLA that is generated from the commands) and the scenarios under which we can benefit from their usage. Topics covered will be the updating of dimensions, measures, partitions, the cube and more. Bio: Steve Simon is an Assistant Vice President with State Street Corporation in Boston. He has been involved with database design and analysis for over 26 years. Steve has presented papers at eight North American PASS Summits (in Orlando, Seattle WA (4), Denver CO (2) and San Francisco CA), two at PASS Europe 2009 and one at PASS Europe 2010. He has just recently presented his PASS 2008 Summit presentation in Johannesburg South Africa. Steve is actively involved with the SQL Server community within the Boston area and is a regular presenter at the New England Code Camps and SQL Saturday events and participates actively on many of the Microsoft User Forums. He is also the Virtual Chapter leader of the Professional Association for SQL Server (PASS) Oracle – SQL Server Virtual Chapter and is a PASS regional mentor. He will also be presenting a data mining paper at SQL Teach in Montreal between May 31st , 2011 and June 3rd 2011. URL: https://www.livemeeting.com/cc/usergroups/join?id=RPN4J9&#38;role=attend&#38;pw=J%25%7E*7r%229d]]></description>
			<content:encoded><![CDATA[<p><a href="http://appdev.sqlpass.org/"><img style="display: inline; float: right;" src="http://www.sqlpass.org/Portals/_default/Skins/pass_skins_fixed_smallbanner/pass_logo.gif" alt="www.sqlpass.org" align="right" /></a><strong>Building Applications That A DBA Will Love<br />
</strong><strong>All About Analysis Services</strong><br />
_____________________________________________________________</p>
<p><strong>Building Applications That A DBA Will Love</strong><strong><br />
</strong><strong>April 12, 2011, 12 PM Eastern</strong><strong><br />
</strong><strong>Presenter: </strong><strong>Andy Warren</strong><strong><br />
Attendee URL:</strong><strong> </strong><a href="https://www.livemeeting.com/cc/usergroups/join?id=N6SZJN&amp;role=attend"><span style="color: #336699;">LiveMeeting</span></a></p>
<p>It’s natural for the focus to be on the end user when we build applications, but it’s important and worthwhile to build into our design some things that make it easier for the DBA to provision, tune, and support the product we deliver. So what does a DBA care about? Performance of course, but also security, scalability, space usage, and yes, even documentation. This presentation will cover tips in a number of areas that address the concerns of the DBA, and we’ll talk about why you should care about making the DBA happy too!</p>
<p><strong>Andy Warren</strong></p>
<p>Andy Warren is a SQL Server consultant and trainer who occasionally writes some code too. He’s on the PASS Board of Directors, was a founding partner in SQLServerCentral.com, started the SQLSaturday event format, and is currently a SQL Server MVP. Andy blogs at <a href="http://www.sqlandy.com/"><span style="color: #336699;">www.sqlandy.com</span></a>, and can be reached via Twitter as @sqlandy and on LinkedIn at <a href="http://www.linkedin.com/in/sqlandy"><span style="color: #336699;">www.linkedin.com/in/sqlandy</span></a>.</p>
<p><strong>How do I attend?</strong><strong><br />
<strong>Attendee URL: </strong></strong><a href="https://www.livemeeting.com/cc/usergroups/join?id=N6SZJN&amp;role=attend"><span style="color: #336699;">LiveMeeting</span></a><br />
_____________________________________________________________</p>
<p><strong><span style="font-size: small;">Efficient and effective processing of OLAP CUBES with AMO and XMLA<br />
Fri April 15th 12PM EST (US)<br />
Speaker: Steve Simon</span></strong></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;"><strong>Topic Description: </strong></span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Within the financial industry, rapid and effective decision making is critical to our client relationships. Analytical tools such as OLAP cubes help make this a reality. In many 24 X 7 enterprises, data capture and cube updates occur on an ongoing basis throughout the business day. We are able to achieve this through the innovative utilization of SQL Server Integration Services (SSIS). This intermediate level hands-on presentation will show the attendee how we have utilized Analysis Management Objects (AMO) commands and SSIS to ‘fire’ our OLAP CUBE updating processes. The presentation will discuss the high level concepts behind Analysis Management Objects (and the XMLA that is generated from the commands) and the scenarios under which we can benefit from their usage. Topics covered will be the updating of dimensions, measures, partitions, the cube and more.</span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;"><strong>Bio:</strong></span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Steve Simon is an Assistant Vice President with State Street Corporation in Boston. He has been involved with database design and analysis for over 26 years. Steve has presented papers at eight North American PASS Summits (in Orlando, Seattle WA (4), Denver CO (2) and San Francisco CA), two at PASS Europe 2009 and one at PASS Europe 2010. He has just recently presented his PASS 2008 Summit presentation in Johannesburg South Africa. Steve is actively involved with the SQL Server community within the Boston area and is a regular presenter at the New England Code Camps and SQL Saturday events and participates actively on many of the Microsoft User Forums. He is also the Virtual Chapter leader of the Professional Association for SQL Server (PASS) Oracle – SQL Server Virtual Chapter and is a PASS regional mentor. He will also be presenting a data mining paper at SQL Teach in Montreal between May 31<sup>st</sup> , 2011 and June 3<sup>rd</sup> 2011.</span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;"><strong>URL:</strong> <a href="https://www.livemeeting.com/cc/usergroups/join?id=RPN4J9&amp;role=attend&amp;pw=J%25%7E*7r%229d">https://www.livemeeting.com/cc/usergroups/join?id=RPN4J9&amp;role=attend&amp;pw=J%25%7E*7r%229d</a></span></span></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/LDRlpbOjwao" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/04/mid-april-free-training-from-pass-vcs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/04/mid-april-free-training-from-pass-vcs/</feedburner:origLink></item>
		<item>
		<title>Getting Priorities Done</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/u_P8dyjK3yc/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/04/getting-priorities-done/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 18:56:53 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2201</guid>
		<description><![CDATA[﻿ Getting Priorities Done Last year I kept hearing about all these people using something called GTD (Getting Things Done).  They didn’t talk about it much.  But occasionally one of them would send out an excited tweet mentioning GTD.  I got tired of hearing all these excited tweets and finally decided to dive in.  I had actually purchased the audiobook of GTD years ago but never got around to listening to it.  I was only a few pages into the book when I had the urge to make a big list of everything I have to finish.  I started out putting everything into a spreadsheet.  Everything from “Script new Mount Point Daily Check Job” to “Remember to pickup dry cleaning” was going into this list.  I would frequently realize that I was behind on a certain task; so I’d stop and take care of that item.  After 6 hours I was in love with this technique.  After 18 hours I was slightly overwhelmed.  And after  48 hours I was ready to quit.  I had a list of over 80 items, and adding to that list did help me finish any of those items.  In fact the list left me feeling that life was more out of control than before my to-do items were written on paper.  I couldn’t understand how anyone –let alone all these people I had heard of – could get anything done using method.  Like my first attempts with PowerShell, I closed it down and decided it wasn’t very useful. At the same time I had just started a new job much closer to home.  I had an extra hour available for every workday, but I was accomplishing less than ever.  It felt weird.  Almost everything was in place – so much so that I felt anyone should be able to succeed given these conditions – and yet I wasn’t!  I wasn’t getting to the gym more, I wasn’t spending significantly more time with my daughter and I wasn’t all that much less stressed. I took a while, but after seeing that list and realizing how much was there I recognized that, short of having two clones, I was never going to be done with my to-do list.  What to do?  Simple.  That list must be shorter. With the writing on the wall I decided to categorize the things on my now out of date GTD list and see what I could scrap.  To say it was a punch in the face would like saying Southerners like Barbeque.  “It ain’t dinner unless a pig had to die.”  Right now my daughter is 13 and still listens to me at least pretends to listen when I speak.  I’m not sure how much longer that will last.  Her school is 2.2 miles away from both our home and my office  (For those playing at home, that is a 12 minute Atlanta commute. ). At the end of the day life is about priorities and I’ve finally figured mine out. So until my daughter stops letting me drop her off at school, play taxi-cab for her and her friends, and generally allows me to be seen with her in public… well, I’m not going to have a lot of free time to do much else So what does that mean?  Am I going to stop blogging, writing, speaking, everything?  I don’t know, quite possibly.  Maybe for a while, maybe for a good while.  I have two items in my Professional Development category that I’ve committed to get done (and thankfully they both won’t take up very much time at all).   I’m still going to finish those two and they might result in some interesting content.  But for everything else?  Well following the GTD method those are all marked as “Maybe-Some Day”.]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" class="mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;">﻿</div>
<div>
<p><span style="font-size: xx-large;"><span style="color: #17365d;"><span style="font-family: Cambria;">Getting Priorities Done</span></span></span></p>
</div>
<p><span style="font-size: medium;"><span style="font-family: Calibri;">Last year I kept hearing about all these people using something called GTD (Getting Things Done).  They didn’t talk about it much.  But occasionally one of them would send out an excited tweet mentioning GTD.  I got tired of hearing all these excited tweets and finally decided to dive in.  I had actually purchased the audiobook of GTD years ago but never got around to listening to it.  I was only a few pages into the book when I had the urge to make a big list of everything I have to finish.  I started out putting everything into a spreadsheet.  Everything from “Script new Mount Point Daily Check Job” to “Remember to pickup dry cleaning” was going into this list.  I would frequently realize that I was behind on a certain task; so I’d stop and take care of that item.  </span></span></p>
<p><span style="font-size: medium;"><span style="font-family: Calibri;">After 6 hours I was in love with this technique.  After 18 hours I was slightly overwhelmed.  And after  48 hours I was ready to quit.  I had a list of over 80 items, and adding to that list did help me finish any of those items.  In fact the list left me feeling that life was more out of control than before my to-do items were written on paper.  I couldn’t understand how anyone –let alone all these people I had heard of – could get anything done using method.  Like my first attempts with PowerShell, I closed it down and decided it wasn’t very useful.</span></span></p>
<p><span style="font-size: medium;"><span style="font-family: Calibri;">At the same time I had just started a new job much closer to home.  I had an extra hour available for every workday, but I was accomplishing less than ever.  It felt weird.  Almost everything was in place – <em>so much so that I felt anyone should be able to succeed given these conditions</em> – and yet I wasn’t!  I wasn’t getting to the gym more, I wasn’t spending significantly more time with my daughter and I wasn’t all that much less stressed. </span></span></p>
<p><span style="font-size: medium;"><span style="font-family: Calibri;">I took a while, but after seeing that list and realizing how much was there I recognized that, short of having two clones, I was never going to be done with my to-do list.  What to do?  Simple.  That list must be shorter. With the writing on the wall I decided to categorize the things on my now out of date GTD list and see what I could scrap.  To say it was a punch in the face would like saying Southerners like Barbeque.  “It ain’t dinner unless a pig had to die.”  Right now my daughter is 13 and still <span style="text-decoration: line-through;">listens to me</span> at least pretends to listen when I speak.  I’m not sure how much longer that will last.  Her school is 2.2 miles away from both our home and my office  (For those playing at home, that is a 12 minute Atlanta commute.</span><span style="font-family: Calibri;"> <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ). At the end of the day life is about priorities and I’ve finally figured mine out. So until my daughter stops letting me drop her off at school, play taxi-cab for her and her friends, and generally allows me to be seen with her in public… well, I’m not going to have a lot of free time to do much else <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </span></span></p>
<p><span style="font-size: medium;"><span style="font-family: Calibri;">So what does that mean?  Am I going to stop blogging, writing, speaking, everything?  I don’t know, quite possibly.  Maybe for a while, maybe for a good while.  I have two items in my Professional Development category that I’ve committed to get done (and thankfully they both won’t take up very much time at all).   I’m still going to finish those two and they might result in some interesting content.  But for everything else?  Well following the GTD method those are all marked as “Maybe-Some Day”.</span></span></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/u_P8dyjK3yc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/04/getting-priorities-done/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/04/getting-priorities-done/</feedburner:origLink></item>
		<item>
		<title>MEME Monday: Taking a Break</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/rS25lptemS8/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/04/meme-monday-taking-a-break/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 12:55:40 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2198</guid>
		<description><![CDATA[Taking a break to spend more time with my daughter Dorothy. &#8211; Thanks for the idea Tom]]></description>
			<content:encoded><![CDATA[<p>Taking a break to spend more time with my daughter Dorothy.</p>
<p>&#8211; Thanks for the <a href="http://thomaslarock.com/2011/03/meme-monday/">idea</a> Tom</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/rS25lptemS8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/04/meme-monday-taking-a-break/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/04/meme-monday-taking-a-break/</feedburner:origLink></item>
		<item>
		<title>Help Promote SQLRally!</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/bFtq1tvWYDE/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/02/help-promote-sqlrally/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 03:39:32 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[SQLRally]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/02/help-promote-sqlrally/</guid>
		<description><![CDATA[In case you’re in need of some images to help us promote the largest PASS event on the East Coast this year, I’ve gathered some together for you For all you chapter leaders I’ve also included a flyer that you can print out and hand out at your user group meeting or SQL Saturday. You can right-click save-as on these or just grab this zip with everything. This one would look great in your email signature! This one would look great in the tight-hand column of your blog Or this one: If you’re using the PrimePress theme like me you’ll want to put this under /wp-content/themes/primepress/headers]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Logo_Dell_Web.jpg"><img title="SQLRally_Logo_Dell_Web" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Logo_Dell_Web_thumb.jpg" border="0" alt="SQLRally_Logo_Dell_Web" width="182" height="86" align="right" /></a>In case you’re in need of some images to help us promote the largest PASS event on the East Coast this year, I’ve gathered some together for you <img style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/wlEmoticon-smile2.png" alt="Smile" class="wlEmoticon wlEmoticon-smile" /> For all you chapter leaders I’ve also included a <a href="http://SQLvariant.com/BlogSupport/Images/SQL_Flyer_Update_12_13_10.pdf">flyer</a> that you can print out and hand out at your user group meeting or SQL Saturday.  You can right-click save-as on these or just grab <strong><a href="http://SQLvariant.com/BlogSupport/Images/SQLRally.zip">this zip</a></strong> with everything.</p>
<h3>This one would look great in your email signature!</h3>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally.jpg"><img title="SQLRally" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_thumb.jpg" border="0" alt="SQLRally" width="177" height="102" align="left" /></a></p>
<h3></h3>
<h4>This one would look great in the tight-hand column of your blog <img style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/wlEmoticon-smile2.png" alt="Smile" class="wlEmoticon wlEmoticon-smile" /></h4>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Banner_240x120_1.jpg"><img title="SQLRally_Banner_240x120_1" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Banner_240x120_1_thumb.jpg" border="0" alt="SQLRally_Banner_240x120_1" width="124" height="244" /></a></p>
<h4>Or this one:</h4>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Banner_240x120_2.jpg"><img title="SQLRally_Banner_240x120_2" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Banner_240x120_2_thumb.jpg" border="0" alt="SQLRally_Banner_240x120_2" width="124" height="244" /></a></p>
<h4>If you’re using the PrimePress theme like me you’ll want to put this under /wp-content/themes/primepress/headers</h4>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Banner_728x90.jpg"><img title="SQLRally_Banner_728x90" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/SQLRally_Banner_728x90_thumb.jpg" border="0" alt="SQLRally_Banner_728x90" width="595" height="78" /></a></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/bFtq1tvWYDE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/02/help-promote-sqlrally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/02/help-promote-sqlrally/</feedburner:origLink></item>
		<item>
		<title>Emailing tempdb Query Results to Paul Randal with PowerShell</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/typDc-PfSNw/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/02/emailing-tempdb-query-results-to-paul-randal-with-powershell/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 19:27:52 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/02/emailing-tempdb-query-results-to-paul-randal-with-powershell/</guid>
		<description><![CDATA[I was referred to someone on twitter today who wants to email query results without setting up database mail.  I explained this in Post 6 of PowerShell Week at SQL University but that example was somewhat complicated. Instead, I thought I’d whip up a new example using Paul’s latest survey.  Paul want’s to know know how many cores your instances have and how many data files that tempdb has. Paul’s query is pretty simple: SELECT os.Cores, df.Files FROM (SELECT COUNT(*) AS Cores FROM sys.dm_os_schedulers WHERE status = 'VISIBLE ONLINE') AS os, (SELECT COUNT(*) AS Files FROM tempdb.sys.database_files WHERE type_desc = 'ROWS') AS df; GO I simply took that query and wrapped it with almost the same code that I used at SQL University.  The difference allows me to show off two new tricks.  First, I separated out the part that grabs the list of servers from your Registered Servers to happen before the foreach loop.  I had received feedback from a reader that A) Having it there made it hard to read on my website, and B) it simplified the logic flow.  It also has the added benefits of performing faster when you’re running against hundreds of instances like me, and making it a little more clear how to swap it out when you want to use something besides Registered Servers to list your instances.  For more information on the different data sources that you can use for reading in a list of servers have a look here at Post 5. Second I added this $S++; it is a little piece of code to enumerate the instances for you.  Last time I had written the results to a table and then read them out using DENSE_RANK but since we don’t have multiple results this time [and because I love showing off cool PowerShell code] I used this instead. $ServerList = dir -recurse SQLSERVER:\SQLRegistration\'Database Engine Server Group'\ &#124; where {$_.Mode -ne "d"} foreach ($RegisteredSQLs in $ServerList ) { $S++; $dt+=invoke-sqlcmd2 -ServerInstance $RegisteredSQLs.ServerName -database master -Query " (SELECT COUNT(*) AS Cores FROM sys.dm_os_schedulers WHERE status = 'VISIBLE ONLINE') AS os, (SELECT COUNT(*) AS Files FROM tempdb.sys.database_files WHERE type_desc = 'ROWS') AS df" -As 'DataTable' } $MultipleResults = $dt &#124; ConvertTo-Html -Property Instance, Cores, Files &#124; Out-String; Send-MailMessage -To paul@SQLskills.com ` -Subject "tempdb Survey Results" ` –From YourEmailAddress@GoesHere.com ` -SmtpServer YourSMTPServerGoesHere ` -Body $MultipleResults -BodyAsHtml Hopefully this will help you email query results to your heart&#8217;s content   Big thanks to TJay Belt ( blog &#124; @TJayBelt ) for pointing out this request on the #SQLHelp hotline to me.  I&#8217;ve done this tons of times myself and I LOVE that anyone can walk up with a question and when people don&#8217;t have the answer they still do what they can to help them out right away.  I less than three community!! Please Note: DO NOT SPAM Paul Randal! You should probably try emailing this to yourself a time or two before you decide to send it to him. I’m using Chad Miller’s (Blog&#124;Twitter) invoke-sqlcmd2 to output the results as a data table (you’ll need that). Finally a friendly reminder that unlike SQL Server, PowerShell persists variables so if you run this multiple times you’ll want to clear out the $dt variable like this: $dt=$null.]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/image3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/image_thumb1.png" border="0" alt="image" width="476" height="159" align="right" /></a>I was referred to someone on twitter today who wants to email query results without setting up database mail.  I explained this in <a href="http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-6/"><strong>Post 6 of PowerShell Week at SQL University</strong></a> but that example was somewhat complicated. Instead, I thought I’d whip up a new example using <a href="http://www.sqlskills.com/BLOGS/PAUL/post/Survey-how-is-your-tempdb-configured.aspx">Paul’s latest survey</a>.  Paul want’s to know know how many cores your instances have and how many data files that tempdb has.</p>
<p>Paul’s query is pretty simple:</p>
<p><code style="font-size: 12px;"><span style="color: blue;">SELECT </span><span style="color: black;">os.Cores</span><span style="color: gray;">, </span><span style="color: black;">df.Files<br />
</span><span style="color: blue;">FROM<br />
</span><span style="color: gray;">(</span><span style="color: blue;">SELECT </span><span style="color: magenta;">COUNT</span><span style="color: gray;">(*) </span><span style="color: blue;">AS </span><span style="color: black;">Cores </span><span style="color: blue;">FROM </span><span style="color: black;"><span style="color: #008000;">sys.dm_os_schedulers</span> </span><span style="color: blue;">WHERE </span><span style="color: black;">status </span><span style="color: blue;">= </span><span style="color: red;">'VISIBLE ONLINE'</span><span style="color: gray;">) </span><span style="color: blue;">AS </span><span style="color: black;">os</span><span style="color: gray;">,<br />
(</span><span style="color: blue;">SELECT </span><span style="color: magenta;">COUNT</span><span style="color: gray;">(*) </span><span style="color: blue;">AS </span><span style="color: black;">Files </span><span style="color: blue;">FROM </span><span style="color: black;"><span style="color: #008000;">tempdb.sys.database_files</span> </span><span style="color: blue;">WHERE </span><span style="color: black;">type_desc </span><span style="color: blue;">= </span><span style="color: red;">'ROWS'</span><span style="color: gray;">) </span><span style="color: blue;">AS </span><span style="color: black;">df</span><span style="color: gray;">;<br />
</span><span style="color: black;">GO</span></code></p>
<p>I simply took that query and wrapped it with <span style="text-decoration: underline;"><em>almost</em></span> the same code that I used at SQL University.  The difference allows me to show off two new tricks.  <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/wlEmoticon-smile1.png" alt="Smile" /></p>
<ul>
<li>First, I separated out the part that grabs the list of servers from your Registered Servers to happen <em>before</em> the foreach loop.  I had received feedback from a reader that A) Having it there made it hard to read on my website, and B) it simplified the logic flow.  It also has the added benefits of performing faster when you’re running against hundreds of instances like me, and making it a little more clear how to swap it out when you want to use something besides Registered Servers to list your instances.  For more information on the different data sources that you can use for reading in a list of servers have a look here at <a href="http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-5/">Post 5</a>.</li>
<li>Second I added this <span style="color: #ff4500;">$S</span><span style="color: #a9a9a9;">++</span><span style="color: #000000;">;</span> it is a little piece of code to enumerate the instances for you.  Last time I had written the results to a table and then read them out using DENSE_RANK but since we don’t have multiple results this time [and because I love showing off cool PowerShell code] I used this instead.</li>
</ul>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$ServerList</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">dir</span> <span style="color: #000080;">-recurse</span> <span style="color: #8a2be2;">SQLSERVER:\SQLRegistration\'Database Engine Server Group'\</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Mode</span> <span style="color: #a9a9a9;">-ne</span> <span style="color: #8b0000;">"d"</span><span style="color: #000000;">}</span>            

<span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$RegisteredSQLs</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$ServerList</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #ff4500;">$S</span><span style="color: #a9a9a9;">++</span><span style="color: #000000;">;</span>
<span style="color: #ff4500;">$dt</span><span style="color: #a9a9a9;">+=</span><span style="color: #0000ff;">invoke-sqlcmd2</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">"
    (SELECT COUNT(*) AS Cores FROM sys.dm_os_schedulers WHERE status = 'VISIBLE ONLINE') AS os,
    (SELECT COUNT(*) AS Files FROM tempdb.sys.database_files WHERE type_desc = 'ROWS') AS df"</span> <span style="color: #000080;">-As</span> <span style="color: #8b0000;">'DataTable'</span>
<span style="color: #000000;">}</span>            

<span style="color: #ff4500;">$MultipleResults</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$dt</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">ConvertTo-Html</span> <span style="color: #000080;">-Property</span> <span style="color: #8a2be2;">Instance</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Cores</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Files</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Out-String</span><span style="color: #000000;">;</span>            

<span style="color: #0000ff;">Send-MailMessage</span> <span style="color: #000080;">-To</span> <span style="color: #8a2be2;">paul@SQLskills.com</span> <span style="color: #000000;">`
</span> <span style="color: #000080;">-Subject</span> <span style="color: #8b0000;">"tempdb Survey Results"</span> <span style="color: #000000;">`
</span> <span style="color: #000080;">–From</span> <span style="color: #8a2be2;">YourEmailAddress@GoesHere.com</span> <span style="color: #000000;">`
</span> <span style="color: #000080;">-SmtpServer</span> <span style="color: #8a2be2;">YourSMTPServerGoesHere</span> <span style="color: #000000;">`
</span> <span style="color: #000080;">-Body</span> <span style="color: #ff4500;">$MultipleResults</span> <span style="color: #000080;">-BodyAsHtml</span></pre>
<p>Hopefully this will help you email query results to your heart&#8217;s content <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   Big thanks to TJay Belt ( <a href="http://tjaybelt.blogspot.com/">blog</a> | <a href="http://twitter.com/tjaybelt">@TJayBelt</a> ) for pointing out this request on the <a href="http://twitter.com/#search?q=%23SQLHelp">#SQLHelp hotline</a> to me.  I&#8217;ve done this tons of times myself and I LOVE that anyone can walk up with a question and when people don&#8217;t have the answer they still do what they can to help them out right away.  I <em>less than three</em> community!!</p>
<blockquote><p>Please Note:</p>
<p>DO NOT SPAM Paul Randal! You should probably try emailing this to yourself a time or two before you decide to send it to him.</p>
<p>I’m using Chad Miller’s (<a href="http://sev17.com/">Blog</a>|<a href="http://www.twitter.com/cmille19">Twitter</a>) <a href="http://gallery.technet.microsoft.com/ScriptCenter/en-us/7985b7ef-ed89-4dfd-b02a-433cc4e30894"><strong>invoke-sqlcmd2 </strong></a>to output the results as a data table (you’ll need that).</p>
<p>Finally a friendly reminder that unlike SQL Server, PowerShell persists variables so if you run this multiple times you’ll want to clear out the $dt variable like this: <span style="color: #ff4500;">$dt</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$null.</span></p></blockquote>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/typDc-PfSNw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/02/emailing-tempdb-query-results-to-paul-randal-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/02/emailing-tempdb-query-results-to-paul-randal-with-powershell/</feedburner:origLink></item>
		<item>
		<title>PowerShell Interfaces with Other Hammers</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/NTfzzLOR7YY/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/02/powershell-interfaces-with-other-hammers/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 04:43:56 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Syndicated]]></category>
		<category><![CDATA[TSQL2sDay]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/02/powershell-interfaces-with-other-hammers/</guid>
		<description><![CDATA[This month&#8217;s installment of T-SQL Tuesday is hosted by Pat Wright (blog &#124; twitter). Pat says: &#8220;So the topic I have chosen for this month is Automation! It can be Automation with T-SQL or with PowerShell or a mix of both. Give us your best tips/tricks and ideas for making our lives easier through Automation.&#8221; I have to tell you, this doesn’t get old: I love that somebody on the other side of the planet is telling someone else that I ‘probably have a PowerShell script to solve their problem’. The funny thing is that a lot of the time I don’t have a script for the problem they’re trying to solve *yet*. I love it when someone gets referred to me and I don’t have a script because it gives me a chance to go explore the language and figure out something I don’t know. PowerShell makes this quest pretty fast. Ironically Paul White ( blog &#124; twitter ) didn’t know I had a script for that, he was just making a joke. Well, actually, I didn’t have a script for that. I did however know right where to find the person that did; and that is even better than if I had a script of my own. Why is it better that I had to point someone some where else? Could I not have figured this script out own my own? No that’s not it at all. PowerShell is NOT a hammer it’s an Automation Language. Better yet PowerShell is a Toolset, and it happens to come with some pretty freaking awesome hammers built in. We all understand that SQL Server isn’t just a hammer, that it’s an entire toolset. Inside of that toolset is: T-SQL, SQL Agent, Profiler, SSIS, the SMO, SSRS, SSAS etc… just to name a few. The cool thing about PowerShell is it’s actually built to work with other hammers. So the reason that you hear me talking about PowerShell all the time is not because I’m replacing my T-SQL Hammer, I’m just automating it! Like this, here’s a quick script to figure out how long your SQL 2008+ instances have been running: &#60;# Number of Days since the Instance has been restarted #&#62; $InstanceList = "WIN7NetBook", "WIN7NetBook\R2", "WIN7NetBook\SQLExpress" foreach($Instance in $InstanceList) { Invoke-Sqlcmd -Query "SELECT @@SERVERNAME AS 'ServerName' , DATEDIFF(D, Sqlserver_start_time, SYSDATETIME()) AS 'NumberOfDays' FROM sys.dm_os_sys_info" -ServerInstance $Instance -Database master } The automation doesn’t stop with SQL Server. You can find plenty of posts form people in our SQL Community on working with things like Red-Gate’s SQL Compare, Outlook, Active Directory, and Subversion just to name a few. The key here is that all of these people are automating something adjacent to their SQL world and they’re using PowerShell to make it happen. Heck just last week I wanted to know how many sessions had been submitted to SQL Saturday #67 in Chicago. Do you think I went to the schedule page, copied the list of sessions into Excel and then checked to see what line number the last session was on to get my count?? Heck NO!! Last year I wrote a script for Allen Kinsel ( blog &#124; twitter ) to count how many people at the PASS Summit had registered their twitter handle when the signed up. I took that script, changed the link, changed the term I was looking for and presto! I now know that 105 sessions have been submitted to SQL Saturday #67. That has nothing to do with SQL Server right?!… Except for that whole bit about it being a SQL Saturday that I was interested in. &#60;#Start up a web client and download the web page into a text file#&#62; $url="http://www.sqlsaturday.com/67/schedule.aspx" $file="c:\temp\DownloadSession$(((Get-Date).ToString("yyyyMMddHHmm"))).txt" $webclient = New-Object system.net.webclient $webclient.DownloadFile($url,$file) &#60;#Sift through the file for lines that include "viewsession" #&#62; (Select-String -path $file -Pattern "viewsession").count OK, so what’s your point? My point is that I wouldn’t have even had the twitter script that I started with if Allen Kinsel hadn’t taken a chance and sent me an email at noon the Friday before the PASS Summit and asked me if I could use PowerShell to count the number of attendees with twitter handles. Again, what’s your point? My point is Use PowerShell to make one tool talk to another. And… And tell people faced with an annoying problem that you think I’ve got a script for that because whose knows, maybe I do!]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlasylum.wordpress.com/2011/02/01/invitation-to-t-sql-tuesday-15-automation-in-sql-server/"><img alt="" style="display: inline; float: right;" src="http://sqlblog.com/files/folders/30073/download.aspx" border="0" hspace="22" width="154" height="154" align="right" /></a>This month&#8217;s installment of T-SQL Tuesday is hosted by Pat Wright (<a href="http://sqlasylum.wordpress.com/">blog</a> | <a href="http://twitter.com/SQLAsylum">twitter</a>). Pat says: &#8220;<em>So the topic I have chosen for this month is Automation! It can be Automation with T-SQL or with PowerShell or a mix of both. Give us your best tips/tricks and ideas for making our lives easier through Automation</em>.&#8221;</p>
<h3>I have to tell you, this doesn’t get old:</h3>
<p><a href="http://twitter.com/#!/SQL_Kiwi/statuses/34802898562973697"><img title="image" alt="image" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/image.png" border="0" width="403" height="225" align="right" /></a>I love that somebody on the other side of the planet is telling someone else that I ‘<em>probably have a PowerShell script to solve their problem</em>’.  The funny thing is that a lot of the time I don’t have a script for the problem they’re trying to solve *yet*.  I love it when someone gets referred to me and I don’t have a script because it gives me a chance to go explore the language and figure out something I don’t know.  PowerShell makes this quest pretty fast.</p>
<p><a href="http://twitter.com/#!/SQL_Kiwi/statuses/34803381813903360"><img title="image" alt="image" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/image1.png" border="0" width="404" height="193" align="right" /></a>Ironically Paul White ( <a href="http://sqlblog.com/blogs/paul_white/default.aspx">blog</a> | <a href="http://twitter.com/SQL_Kiwi">twitter</a> ) didn’t know I had a script for that, he was just making a joke.  Well, actually, <strong>I didn’t have a script for that</strong>. I did however know right where to find the person that did; and that is even better than if I had a script of my own.  Why is it better that I had to point someone some where else?  Could I not have figured this script out own my own?  No that’s not it at all.</p>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/image2.png"><img title="image" alt="image" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/image_thumb.png" border="0" width="389" height="134" align="right" /></a>PowerShell is <strong>NOT</strong> a hammer it’s an <strong>Automation Language</strong>.  Better yet PowerShell is a <span style="color: #000080;">Toolset</span>, and it happens to come with some pretty freaking awesome hammers <span style="text-decoration: underline;">built in</span>.  We all understand that <span style="color: #000080;">SQL Server</span> isn’t just a hammer, that it’s an entire toolset.  Inside of that toolset is: T-SQL, SQL Agent, Profiler, SSIS, the SMO, SSRS, SSAS etc… just to name a few.</p>
<p>The cool thing about PowerShell is it’s actually built to <span style="text-decoration: underline;">work with other hammers</span>.  So the reason that you hear me talking about PowerShell all the time is not because I’m replacing my T-SQL Hammer, I’m just automating it!  Like this, here’s a quick script to figure out how long your SQL 2008+ instances have been running:</p>
<pre class="PowerShellColorizedScript"><span style="color: #006400;">&lt;# Number of Days since the Instance has been restarted #&gt;</span>
<span style="color: #ff4500;">$InstanceList</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"WIN7NetBook"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"WIN7NetBook\R2"</span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;">"WIN7NetBook\SQLExpress"</span>
<span style="color: #00008b;">foreach</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$Instance</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$InstanceList</span><span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">"SELECT @@SERVERNAME AS 'ServerName'
, DATEDIFF(D, Sqlserver_start_time, SYSDATETIME()) AS 'NumberOfDays'
  FROM sys.dm_os_sys_info"</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #ff4500;">$Instance</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">master</span>
<span style="color: #000000;">}</span></pre>
<p>The automation doesn’t stop with SQL Server.  You can find plenty of posts form people in our SQL Community on working with things like <a href="http://www.scarydba.com/2011/01/31/powershell-to-automate-sql-compare/">Red-Gate’s SQL Compare</a>, <a href="http://adventuresinsql.com/2011/01/looking-up-email-addresses-with-powershell/">Outlook</a>, <a href="http://adventuresinsql.com/2011/01/looking-up-email-addresses-with-powershell/">Active Directory</a>, and <a href="http://www.erichumphrey.com/2010/09/upcoming-series-on-source-controlling-your-databases/">Subversion</a> just to name a few.  The key here is that all of these people are automating something adjacent to their SQL world and they’re using PowerShell to make it happen.</p>
<p>Heck just last week I wanted to know how many sessions had been submitted to <a href="http://www.sqlsaturday.com/67/eventhome.aspx">SQL Saturday #67 in Chicago</a>.  Do you think I went to the <a href="http://www.sqlsaturday.com/67/schedule.aspx">schedule page</a>, copied the list of sessions into Excel and then checked to see what line number the last session was on to get my count??  Heck NO!!  Last year I wrote a script for Allen Kinsel ( <a href="http://www.allenkinsel.com/">blog</a> | <a href="http://twitter.com/sqlinsaneo">twitter</a> ) to count how many people at the PASS Summit had registered their twitter handle when the signed up.  I took that script, changed the link, changed the term I was looking for and presto!  I now know that 105 sessions have been submitted to SQL Saturday #67.</p>
<p>That has <span style="text-decoration: underline;">nothing to do with SQL Server</span> right?!…  Except for that whole bit about it being a <strong><span style="text-decoration: underline;">SQL</span></strong> Saturday that I was interested in.</p>
<pre style="width: 641px; height: 180px;" class="PowerShellColorizedScript"><span style="color: #006400;">&lt;#Start up a web client and download the web page into a text file#&gt;</span>
<span style="color: #ff4500;">$url</span><span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"http://www.sqlsaturday.com/67/schedule.aspx"</span>
<span style="color: #ff4500;">$file</span><span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"c:\temp\DownloadSession$(((Get-Date).ToString("yyyyMMddHHmm"))).txt"</span>
<span style="color: #ff4500;">$webclient</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #8a2be2;">system.net.webclient</span>
<span style="color: #ff4500;">$webclient</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">DownloadFile</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$url</span><span style="color: #a9a9a9;">,</span><span style="color: #ff4500;">$file</span><span style="color: #000000;">)</span>            

<span style="color: #006400;">&lt;#Sift through the file for lines that include "viewsession" #&gt;</span>
<span style="color: #000000;">(</span><span style="color: #0000ff;">Select-String</span> <span style="color: #000080;">-path</span> <span style="color: #ff4500;">$file</span> <span style="color: #000080;">-Pattern</span> <span style="color: #8b0000;">"viewsession"</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">count</span></pre>
<p><strong>OK, so what’s your point?</strong></p>
<p>My point is that I wouldn’t have even had the twitter script that I started with if Allen Kinsel hadn’t taken a chance and sent me an email at noon the Friday before the PASS Summit and asked me if I could use PowerShell to count the number of attendees with twitter handles.</p>
<p><strong>Again, what’s your point?</strong></p>
<p>My point is <span style="color: #0000a0;">Use PowerShell to make one tool talk to another</span>.</p>
<p>And…</p>
<p>And tell people faced with an annoying problem that you think I’ve got a script for that because whose knows, <a href="http://blogshell.codeplex.com/">maybe I do</a>!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/NTfzzLOR7YY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/02/powershell-interfaces-with-other-hammers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/02/powershell-interfaces-with-other-hammers/</feedburner:origLink></item>
		<item>
		<title>Recursive Find and Replace Your SQL Files with PowerShell</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/rMcWLUEj_c8/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/02/recursive-find-and-replace-your-sql-files-with-powershell/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 13:59:42 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Find]]></category>
		<category><![CDATA[Find and Replace]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2092</guid>
		<description><![CDATA[This is just a quick blog to help out with something I saw discussed on twitter yesterday. When I do my presentations I have a set of scripts that have the name of the computer and instance I am working with.  I’m not a fan of using localhost or anything like that; I also like to use instance names that let people know what version of SQL that I’m using.  When I switch computers I spend less than a minute changing all of the names.  At the PASS Summit I used a laptop that I had just purchased; here’s the script I used to rename everything. foreach ($SC in dir "$home\Documents\PoSh\" -recurse &#124; where{ Test-Path $_.fullname -pathtype leaf} ) { (Get-Content $SC) &#124; Foreach-Object { $_ -replace 'KILIMANJARO', 'R2' } &#124; Set-Content $SC } To make this work for you just change out the highlighted parts above to whatever you need.  The part that says &#8220;$home\Documents\PoSh\&#8221; will go to the PoSh folder under your “My Documents” directory (If you don’t have one, now’s a good time ).  You can also use a path like C:\SQL\Databases\AdventureQuirks\ here.  The -replace &#8216;KILIMANJARO&#8217;, &#8216;R2&#8242; portion seems pretty self explanatory; same goes for -recurse. If you just wanted to search for all the files with a certain table name, column name, stored proc name, etc… and return a report (not to modify) you can use something like this: #Make sure to navigate to the directory that you want to start looking in: ## cd c:\temp foreach ($SC in dir -recurse &#124; where{ Test-Path $_.fullname -pathtype leaf} ) { Select-String -path $SC -Pattern "WIN7NetBook" } This piece of code is setup slightly different solely to demonstrate another way you can use this functionality.  Make sure that you navigate to directory that you want to search in first for this script.  When you get the results you may end up seeing the same filename listed more that once because the “pattern” appears in the file multiple times.  To make the results show each filename just once simple add -List. One final option that I want to call out is -Filter.  If you want to search for only .SQL files in a directory (or .PS1, .txt, whatever) just add this: -Filter *.SQL So you might end up using something like this: foreach ($SC in dir C:\SQL\Databases\AdventureQuirks\ -recurse -Filter *.SQL &#124; where{ Test-Path $_.fullname -pathtype leaf} ) { Select-String -path $SC -Pattern "WIN7NetBook" } Alright I better stop here before I start showing off some other features that I just learned. Hope that helps!]]></description>
			<content:encoded><![CDATA[<p>This is just a quick blog to help out with something I saw discussed on twitter yesterday.</p>
<p>When I do my presentations I have a set of scripts that have the name of the computer and instance I am working with.  I’m not a fan of using localhost or anything like that; I also like to use instance names that let people know what version of SQL that I’m using.  When I switch computers I spend less than a minute changing all of the names.  At the <a href="http://sqlpass.eventpoint.com/topic/details/DBA237">PASS Summit</a> I used a laptop that I had just purchased; here’s the script I used to rename everything.</p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$SC</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #8b0000;"><span style="background-color: #ffff00;">"$home\Documents\PoSh\"</span></span> <span style="color: #000080;"><span style="background-color: #00ff00;">-recurse</span></span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span><span style="color: #000000;">{</span> <span style="color: #0000ff;">Test-Path</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">fullname</span> <span style="color: #000080;">-pathtype</span> <span style="color: #8a2be2;">leaf</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #000000;">(</span><span style="color: #0000ff;">Get-Content</span> <span style="color: #ff4500;">$SC</span><span style="color: #000000;">)</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Foreach-Object</span> <span style="color: #000000;">{</span> <span style="color: #ff4500;">$_</span> <span style="color: #a9a9a9;">-replace</span> <span style="color: #8b0000;"><span style="background-color: #ffff00;">'KILIMANJARO'</span></span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;"><span style="background-color: #ffff00;">'R2'</span></span> <span style="color: #000000;">}</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Set-Content</span> <span style="color: #ff4500;">$SC</span>
<span style="color: #000000;">}</span></pre>
<blockquote><p>To make this work for <span style="text-decoration: underline;">you</span> just change out the highlighted parts above to whatever you need.  The part that says <span style="color: #8b0000;">&#8220;$home\Documents\PoSh\&#8221;</span> will go to the PoSh folder under your “My Documents” directory (If you don’t have one, now’s a good time <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/02/wlEmoticon-smile.png" alt="Smile" /> ).  You can also use a path like <span style="color: #0000ff;">C:\SQL\Databases\AdventureQuirks\</span> here.  The <span style="color: #a9a9a9;">-replace</span> <span style="color: #8b0000;"><span style="background-color: #ffff00;">&#8216;KILIMANJARO&#8217;</span></span><span style="color: #a9a9a9;">,</span> <span style="color: #8b0000;"><span style="background-color: #ffff00;">&#8216;R2&#8242;</span></span> portion seems pretty self explanatory; same goes for <span style="color: #000080;"><span style="background-color: #00ff00;">-recurse</span></span>.</p></blockquote>
<p>If you just wanted to search for all the files with a certain table name, column name, stored proc name, etc… and return a report (not to modify) you can use something like this:</p>
<pre class="PowerShellColorizedScript"><span style="color: #006400;">#Make sure to navigate to the directory that you want to start looking in:</span>
<span style="color: #006400;">## </span>
<span style="background-color: #ffff00;"><span style="color: #0000ff;">cd</span> <span style="color: #8a2be2;">c:\temp</span></span>            

<span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$SC</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #000080;">-recurse</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span><span style="color: #000000;">{</span> <span style="color: #0000ff;">Test-Path</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">fullname</span> <span style="color: #000080;">-pathtype</span> <span style="color: #8a2be2;">leaf</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #0000ff;">Select-String</span> <span style="color: #000080;">-path</span> <span style="color: #ff4500;">$SC</span> <span style="color: #000080;">-Pattern</span> <span style="color: #8b0000;">"<span style="background-color: #ffff00;">WIN7NetBook</span>"</span>
<span style="color: #000000;">}</span></pre>
<pre class="PowerShellColorizedScript"></pre>
<p>This piece of code is setup slightly different solely to demonstrate another way you can use this functionality.  Make sure that you navigate to directory that you want to search in first for this script.  When you get the results you may end up seeing the same filename listed more that once because the “pattern” appears in the file multiple times.  To make the results show each filename just once simple add <span style="color: #000080;">-List</span>.</p>
<p>One final option that I want to call out is <span style="color: #000080;">-Filter</span>.  If you want to search for only .SQL files in a directory (or .PS1, .txt, whatever) just add this: <span style="color: #000080;">-Filter</span> <span style="color: #8a2be2;">*.SQL</span></p>
<p>So you might end up using something like this:</p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$SC</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #8a2be2;">C:\SQL\Databases\AdventureQuirks\</span> <span style="color: #000080;">-recurse</span> <span style="color: #000080;">-Filter</span> <span style="color: #8a2be2;">*.SQL</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span><span style="color: #000000;">{</span> <span style="color: #0000ff;">Test-Path</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">fullname</span> <span style="color: #000080;">-pathtype</span> <span style="color: #8a2be2;">leaf</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #0000ff;">Select-String</span> <span style="color: #000080;">-path</span> <span style="color: #ff4500;">$SC</span> <span style="color: #000080;">-Pattern</span> <span style="color: #8b0000;">"WIN7NetBook"</span>
<span style="color: #000000;">}</span></pre>
<p>Alright I better stop here before I start showing off some other features that I just learned.<br />
Hope that helps!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/rMcWLUEj_c8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/02/recursive-find-and-replace-your-sql-files-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/02/recursive-find-and-replace-your-sql-files-with-powershell/</feedburner:origLink></item>
		<item>
		<title>Why I Need a Week of SQLskills Immersion</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/6xuXAKznDZg/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/why-i-need-a-week-of-sqlskills-immersion/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 05:09:39 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/01/why-i-need-a-week-of-sqlskills-immersion/</guid>
		<description><![CDATA[SQLskills is giving back to the community with a free seat to their training class in Dallas next month (Feb. 21st – 25th) To answer Paul Randal’s question of why I should get to win a week of training from SQLskills this is what I have to say: Plain and Simple.&#160; I’m a Second Generation DBA with over a decade of experience with SQL Server.&#160; I want some deep level ideas for some new PowerShell scripts to simply tasks for DBAs everywhere.&#160; I’ll also spend countless hours telling all my fellow DBAs here in Atlanta what all I learned until they can take it no more and demand this level of top-notch training for themselves!&#160; I’ll get started with the PowerShell scripts right now even.&#160; This little script will search twitter for a giver hashtag, in this case: #SQLskills.&#160; It will then save everything it finds off to an XML file and then query it: $SearchHashtag = &#34;sqlskills&#34; $wc = new-object net.webclient $url = &#34;http://search.twitter.com/search.atom?q=%23$SearchHashtag&#34; $OutFile = &#34;c:\temp\Download_$($SearchHashtag)_$([DateTime]::Now.ToString('yyyyMMddHHmmss')).xml&#34; $wc.DownloadString($url) &#124; add-content $OutFile; [xml]$tweetxml = get-content $OutFile $tweetxml.feed.entry &#124; Format-List ($tweetxml.feed.entry).count]]></description>
			<content:encoded><![CDATA[<p>SQLskills is giving back to the community with a free seat to their <a href="http://www.sqlskills.com/Master1-Dallas-20110221.asp">training class in Dallas next month (Feb. 21st – 25th)</a></p>
<p>To answer Paul Randal’s question of <a href="http://www.sqlskills.com/BLOGS/PAUL/post/Master_Immersion_Event_Competition.aspx">why I should get to win a week of training from SQLskills</a> this is what I have to say:</p>
<p>Plain and Simple.&#160; I’m a Second Generation DBA with over a decade of experience with SQL Server.&#160; I want some deep level ideas for some new PowerShell scripts to simply tasks for DBAs everywhere.&#160; I’ll also spend countless hours telling all my fellow DBAs here in Atlanta what all I learned until they can take it no more and demand this level of top-notch training for themselves!&#160; <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/wlEmoticon-openmouthedsmile1.png" /></p>
<p>I’ll get started with the PowerShell scripts right now even.&#160; This little script will search twitter for a giver hashtag, in this case: #SQLskills.&#160; It will then save everything it finds off to an XML file and then query it:</p>
<pre style="width: 539px; height: 280px" class="PowerShellColorizedScript"><span style="color: #ff4500">$SearchHashtag</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;sqlskills&quot;</span>            

<span style="color: #ff4500">$wc</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">new-object</span> <span style="color: #8a2be2">net.webclient</span>
<span style="color: #ff4500">$url</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;http://search.twitter.com/search.atom?q=%23$SearchHashtag&quot;</span>
<span style="color: #ff4500">$OutFile</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;c:\temp\Download_$($SearchHashtag)_$([DateTime]::Now.ToString('yyyyMMddHHmmss')).xml&quot;</span>
<span style="color: #ff4500">$wc</span><span style="color: #a9a9a9">.</span><span style="color: #000000">DownloadString</span><span style="color: #000000">(</span><span style="color: #ff4500">$url</span><span style="color: #000000">)</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">add-content</span> <span style="color: #ff4500">$OutFile</span><span style="color: #000000">;</span>            

<span style="color: #008080">[xml]</span><span style="color: #ff4500">$tweetxml</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">get-content</span> <span style="color: #ff4500">$OutFile</span>            

<span style="color: #ff4500">$tweetxml</span><span style="color: #a9a9a9">.</span><span style="color: #000000">feed</span><span style="color: #a9a9a9">.</span><span style="color: #000000">entry</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Format-List</span>            

<span style="color: #000000">(</span><span style="color: #ff4500">$tweetxml</span><span style="color: #a9a9a9">.</span><span style="color: #000000">feed</span><span style="color: #a9a9a9">.</span><span style="color: #000000">entry</span><span style="color: #000000">)</span><span style="color: #a9a9a9">.</span><span style="color: #000000">count</span>            </pre>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/6xuXAKznDZg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/why-i-need-a-week-of-sqlskills-immersion/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/why-i-need-a-week-of-sqlskills-immersion/</feedburner:origLink></item>
		<item>
		<title>PowerShell Week at SQL University – Post 6</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/hpERtD4ohN8/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-6/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 01:58:00 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Formatting Results]]></category>
		<category><![CDATA[Multiple Instances]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=2062</guid>
		<description><![CDATA[Yesterday we went over some loop constructs to get information out of SQL Server.  While getting the information out is great, as Data Professionals our very next concern is going to be: “ok, where do I put this so that I can refer to it later?” Today we’re going to talk about formatting and storing our results.  Our storage mechanisms are going to be a simple flat file, CSV, and the obvious one, a table.  This post is a little long but it walks you through how to overcome some of the frustrations when I started working with PowerShell over a year ago.  Enough preamble, let’s get started! Output on the screen: Start from the beginning by running this little command: Invoke-Sqlcmd -Query &#8216;SELECT * FROM sysfiles&#8217; -Database MyBigFreakinDatabase -ServerInstance Win7NetBookNow depending on how wide your PowerShell window is open to right now PowerShell will format the data to spool out in the results pain the way it thinks is best.  It may have come out ‘one row at a time’: Invoke-Sqlcmd -Query &#8216;SELECT * FROM sysfiles&#8217; -Database MyBigFreakinDatabase -ServerInstance Win7NetBook &#124; Format-ListOr it may have come out like this: Invoke-Sqlcmd -Query &#8216;SELECT * FROM sysfiles&#8217; -Database MyBigFreakinDatabase -ServerInstance Win7NetBook &#124; Format-Table” so you’ll probably want to get into the habit of putting a “ &#124; Format-Table”  after the end of you queries.  Or if you’re lazy like me:  &#124; FT. When we want to run this cmd (or whatever query you really want to run) against multiple databases we’re going to want to know what database that the data came out of.  We might write something like this foreach ($db in invoke-sqlcmd -query " SELECT name FROM sys.databases WHERE owner_sid !=0x01" -database master -serverinstance Win7NetBook ) { Invoke-Sqlcmd -Query ' SELECT * FROM sysfiles' -ServerInstance Win7NetBook -Database $db.name &#124; Format-Table } But the problem with that is We don’t know for sure which database each file came out of.  I mean if we have logical naming we can guess but that’s all it is, a guess.  What we can do is add our little “$db.name” that we&#8217;re using to pass in the name of our database. foreach ($db in invoke-sqlcmd -query " SELECT name FROM sys.databases WHERE owner_sid !=0x01" -database master -serverinstance Win7NetBook ) {$db.name; Invoke-Sqlcmd -Query ' SELECT * FROM sysfiles' -ServerInstance Win7NetBook -Database $db.name &#124; Format-Table } Object Sidebar: Probably the most important thing for SQL people to know about this language! Believer it or not we’re using object oriented code right now.  In this example we’re pumping a list of databases as objects into a variable and then iterating over that list.  If we examine our object by piping it over to Get-Member “$db &#124; Get-Member” we’ll see that it only has one property but if we had selected more columns it would have had more properties.  Typically objects have more than one property so that’s why we need to add the .name to our $db variable so that we only get the name property. Outputting to a text file: In the PowerShell language to output to a text file we can just use “&#62;” and then give it a filename.  Since we’re inside of a loop we would just keep overwriting that file until we got down to the last database and all that would be in the file would be the info from that last database.  We can also use “&#62;&#62;” which allows us to append to a file like this:  &#62;&#62; C:\temp\MyDatabaseFiles_20110120.txt Side Note: In addition to the &#8220;&#62;&#62;&#8221; we could have also used Out-File –FilePath C:\temp\MyDatabaseFiles_20110120.txt –Append with much the same results.  To make a long story short, use Out-File instead of &#62;&#62; whenever possible. foreach ($db in invoke-sqlcmd -query " SELECT name FROM sys.databases WHERE owner_sid !=0x01" -database master -serverinstance Win7NetBook ) {$db.name; Invoke-Sqlcmd -ServerInstance Win7NetBook -Database $db.name -Query ' SELECT * FROM sysfiles' &#124; Format-Table &#62;&#62; C:\temp\MyDatabaseFiles_20110120.txt } That’s not what we expected was it? There are two main problems with the output when we look at  MyDatabaseFiles_20110120.txt.  First, those database names are missing.  They’re missing because they weren’t in the pipeline in the first place.  Each time that we looped we were executing two different statements not just one; and the database name was only present in the first.  We could fix that by making the first line inside of the loop look like this $db.name &#62;&#62; C:\temp\MyDatabaseFiles_20110120.txt; but we won’t, at least not this time. The second problem is that unless we have the editor open on a really, really wide monitor the output was likely truncated with some “…” at the end.  Now if we changed the output mode Format-List we might avoid that truncation problem but as database professionals “might” rarely cuts it. Using Export-CSV to save off our results: Funny story about Export-CSV later… We’ll fire up a new variable called $MyResults and push our results into it each time that we pass through the loop (sorta~like a temp table but don’t make too strong of a connection to that).  After we complete the loop we will take the results and pass them down the pipeline to the Export-CSV cmdlet.  When we open that file we’ll see nice clean data output that we can save. foreach ($db in Invoke-Sqlcmd -query " SELECT name FROM sys.databases WHERE owner_sid !=0x01" -database master -serverinstance Win7NetBook ) {$db.name; $MyResults += Invoke-Sqlcmd -Query " SELECT DB_NAME(db_id()) AS 'DatabaseName', * FROM sysfiles" -ServerInstance Win7NetBook -Database $db.name } $MyResults &#124; Export-CSV -Path C:\temp\MyDatabaseFiles_20110120.csv -NoTypeInformation Output to a table: I’ve talked about how to save rows to a table a couple of times before.  Do you remember that Wait Stats survey that Paul Randal ( blog &#124; twitter ) did a little while ago?  Well, we have several hundred SQL instances where I work and I wanted to be able to send Paul results from a large number of those servers. The thing is I didn&#8217;t want to have to actually login to each instance, run the query, save off the results, then repeat over and over again.  So I came up with this post.  You can do the same to gather info multiple instances/databases in your environment.  It’s pretty straight-forward and very similar to the CSV example above but with a small pair of changes.  We need the two scripts that I mentioned in the other posts:  Chad Miller’s (Blog&#124;Twitter)  invoke-sqlcmd2 and Write-DataTable functions.  Once we have those loaded (and hopefully their in our profile by now ) we’re off to the races being able to write information from multiple databases back into a single database. foreach ($db in invoke-sqlcmd -query " SELECT name FROM sys.databases WHERE owner_sid !=0x01" -database master -serverinstance Win7NetBook) { $dt=invoke-sqlcmd2 -Query " SELECT DB_NAME(db_id()) AS 'DatabaseName', * FROM sysfiles" -ServerInstance Win7NetBook -Database $db.name -As 'DataTable' Write-DataTable -ServerInstance Win7NetBook -Database CentralInfo -TableName dbFileName -Data $dt } Here&#8217;s the SQL code to create that table so that you can test it out: CREATE TABLE [dbo].[dbFileName]( [DatabaseName] [nvarchar](128) NULL, [fileid] [smallint] NULL, [groupid] [smallint] NULL, [size] [int] NOT NULL, [maxsize] [int] NOT NULL, [growth] [int] NOT NULL, [status] [int] NULL, [perf] [int] NULL, [name] [sysname] NOT NULL, [filename] [nvarchar](260) NOT NULL ) ON [PRIMARY] Output to Email: Call me lazy but… I put this next script together just to see if it could be done.  Going back to that Wait Stats Survey, if you read all the way to the end you&#8217;ll see I managed to get the collection process down to 3 lines.  The only thing is that you still had to do something to the result set to exclude your instance names for security, and then after that you still had to do the whole copy-paste thing. To combat all that wasted time I came up with this script which will go ahead and enumerate the instances for you.  That way if for any reason Paul emailed you back and said &#8216;Holy Crap, how the hell did you manage to get that as your highest wait on Instnce #14?&#8217; you&#8217;d still be able to go back and figure out which server he was talking about.  Also, If you would still have the results around in case you wanted to be proactive and take a look yourself (but let&#8217;s not get too carried away). foreach ($RegisteredSQLs in dir -recurse SQLSERVER:\SQLRegistration\'Database Engine Server Group'\ &#124; where {$_.Mode -ne "d"} ) { $dt=invoke-sqlcmd2 -ServerInstance $RegisteredSQLs.ServerName -database master -InputFile ./PaulAndGlensWaitQuery.sql -As 'DataTable' Write-DataTable -ServerInstance "Win7NetBook" -Database CentralInfo -TableName TopWaitTypes -Data $dt } $MultipleResults = Invoke-Sqlcmd2 -ServerInstance "Win7NetBook" -Database CentralInfo -Query "SELECT DENSE_RANK() OVER (ORDER BY [InstanceName]) AS 'SQLInstance' ,[WaitType] ,[Wait_S] ,[Resource_S] ,[Signal_S] ,[WaitCount] ,[Percentage] FROM [CentralInfo].[dbo].[TopWaitTypes] ORDER BY SQLInstance, Percentage" &#124; ConvertTo-Html -Property SQLInstance, WaitType, Wait_S, Resource_S, Signal_S, WaitCount, Percentage &#124; Out-String; Send-MailMessage -To paul@SQLskills.com -Subject "Wait Stats Query Results" –From YourEmailAddress@GoesHere.com -SmtpServer smtp.SQLvariant.com -Body $MultipleResults -BodyAsHtml Finally, you know we could put that SELECT statement into a .sql file.  That would cut it back down to ~6 lines.  We might even be able to wrap the email portion into something a little smaller but considering all that this script does I think this is good enough. It’s Later When I first tried to do something like this I was was shocked to find out that there is no –Append switch for Export-CSV.  I wasn’t very happy about that, I mean I couldn’t wrap my head around [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlvariant.com/wordpress">Yesterday</a> we went over some loop constructs to get information <span style="text-decoration: underline;">out</span> of SQL Server.  While getting the information out is great, as Data Professionals our very next concern is going to be: “ok, where do I put this so that I can refer to it later?”</p>
<p>Today we’re going to talk about formatting and storing our results.  Our storage mechanisms are going to be a simple <strong>flat file</strong>, <strong>CSV</strong>, and the obvious one, a <strong>table</strong>.  This post is a little long but it walks you through how to overcome some of the frustrations when I started working with PowerShell over a year ago.  Enough preamble, let’s get started!</p>
<h3><span style="color: #004080;"><span style="font-weight: bold;">Output on the screen:</span></span></h3>
<p>Start from the beginning by running this little command:</p>
<p><span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">&#8216;SELECT * FROM sysfiles&#8217;</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">MyBigFreakinDatabase</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8a2be2;">Win7NetBook</span>Now depending on how wide your PowerShell window is open to right now PowerShell will format the data to spool out in the results pain the way it thinks is best.  It may have come out ‘one row at a time’:</p>
<p><span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">&#8216;SELECT * FROM sysfiles&#8217;</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">MyBigFreakinDatabase</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Format-List</span>Or it may have come out like this:</p>
<p><span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">&#8216;SELECT * FROM sysfiles&#8217;</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">MyBigFreakinDatabase</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Format-Table</span>” so you’ll probably want to get into the habit of putting a “<span style="color: #a9a9a9;"> |</span> <span style="color: #0000ff;">Format-Table</span>”  after the end of you queries.  Or if you’re lazy like me:  <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">FT</span>.</p>
<p>When we want to run this cmd (or whatever query you really want to run) against multiple databases we’re going to want to know what database that the data came out of.  We might write something like this</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 209px;"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$db</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">" SELECT name FROM sys.databases WHERE owner_sid !=0x01"</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">' SELECT * FROM sysfiles'</span>  <span style="color: #000080;">-ServerInstance</span>  <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Format-Table</span>
<span style="color: #000000;">}</span></pre>
<p>But the problem with that is We don’t know for sure which database each file came out of.  I mean if we have logical naming we can guess but that’s all it is, a guess.  What we can do is add our little “<span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name”</span> that we&#8217;re using to pass in the name of our database.</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 207px;"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$db</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">" SELECT name FROM sys.databases WHERE owner_sid !=0x01"</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span><span style="background-color: #ffff00;"><span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span><span style="color: #000000;">;</span></span>
<span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">' SELECT * FROM sysfiles'</span>  <span style="color: #000080;">-ServerInstance</span>  <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Format-Table</span>
<span style="color: #000000;">}</span></pre>
<blockquote><p><strong>Object Sidebar:</strong> Probably the most important thing for SQL people to know about this language!</p>
<p>Believer it or not we’re using object oriented code right now.  In this example we’re pumping a list of databases as objects into a variable and then iterating over that list.  If we examine our object by piping it over to Get-Member “<span style="color: #ff4500;">$db</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Get-Member</span>” we’ll see that it only has one property but if we had selected more columns it would have had more properties.  Typically objects have more than one property so that’s why we need to add the <strong>.name</strong> to our <span style="color: #ff4500;"><strong>$db</strong></span> variable so that we only get the name property.</p></blockquote>
<h3><span style="color: #004080; font-weight: bold;">Outputting to a text file:</span></h3>
<p>In the PowerShell language to output to a text file we can just use “&gt;” and then give it a filename.  Since we’re inside of a loop we would just keep overwriting that file until we got down to the last database and all that would be in the file would be the info from that last database.  We can also use “&gt;&gt;” which allows us to append to a file like this:  <span style="color: #a9a9a9;">&gt;&gt;</span> <span style="color: #8a2be2;">C:\temp\MyDatabaseFiles_20110120.txt</span></p>
<blockquote><p><strong>Side Note:</strong> In addition to the &#8220;&gt;&gt;&#8221; we could have also used <span style="color: #0000ff;">Out-File</span> –<span style="color: #000080;">FilePath <span style="color: #8a2be2;">C:\temp\MyDatabaseFiles_20110120.txt</span></span> –<span style="color: #000080;">Append </span>with much the same results.  To make a long story short, use Out-File instead of &gt;&gt; whenever possible.</p></blockquote>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 207px;"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$db</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">" SELECT name FROM sys.databases WHERE owner_sid !=0x01"</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span><span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span><span style="color: #000000;">;</span>
<span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-ServerInstance</span>  <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">' SELECT * FROM sysfiles'</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Format-Table</span> <span style="color: #a9a9a9;">&gt;&gt;</span> <span style="color: #8a2be2;">C:\temp\MyDatabaseFiles_20110120.txt</span>
<span style="color: #000000;">}</span></pre>
<p><strong>That’s not what we expected was it?</strong></p>
<p>There are two main problems with the output when we look at  MyDatabaseFiles_20110120.txt.  First, those <span style="text-decoration: underline;">database names are missing</span>.  They’re missing because they weren’t in the pipeline in the first place.  Each time that we looped we were executing two different statements not just one; and the database name was only present in the first.  We <em>could</em> fix that by making the first line inside of the loop look like this <span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span> <span style="color: #a9a9a9;">&gt;&gt;</span> <span style="color: #8a2be2;">C:\temp\MyDatabaseFiles_20110120.txt<span style="color: #000000;"><strong>; </strong>but we won’t, at least not this time</span></span>.</p>
<p>The second problem is that unless we have the editor open on a really, really wide monitor the output was likely truncated with some “…” at the end.  Now if we changed the output mode <span style="color: #0000ff;">Format-List</span> we might avoid that truncation problem but as database professionals “might” rarely cuts it.</p>
<h3><span style="color: #004080;"><strong>Using Export-CSV to save off our results:</strong></span></h3>
<p><strong></strong><em>Funny story about Export-CSV later…</em></p>
<p>We’ll fire up a new variable called <span style="color: #ff4500;">$MyResults</span> and push our results into it each time that we pass through the loop (sorta~like a temp table but don’t make too strong of a connection to that).  After we complete the loop we will take the results and pass them down the pipeline to the Export-CSV cmdlet.  When we open that file we’ll see nice clean data output that we can save.</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 251px;"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$db</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">" SELECT name FROM sys.databases WHERE owner_sid !=0x01"</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span><span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span><span style="color: #000000;">;</span>
<span style="background-color: #ffff00;"><span style="color: #ff4500;">$MyResults</span> <span style="color: #a9a9a9;">+=</span></span> <span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">" SELECT DB_NAME(db_id()) AS 'DatabaseName', * FROM sysfiles"</span>  <span style="color: #000080;">-ServerInstance</span>  <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span>
<span style="color: #000000;">}</span>            

<span style="background-color: #ffff00;"><span style="color: #ff4500;">$MyResults</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Export-CSV</span> <span style="color: #000080;">-Path</span> <span style="color: #8a2be2;">C:\temp\MyDatabaseFiles_20110120.csv</span> <span style="color: #000080;">-NoTypeInformation</span></span></pre>
<h3><span style="color: #004080;"><span style="font-weight: bold;">Output to a table:</span></span></h3>
<p>I’ve talked about how to save rows to a table a couple of times before.  Do you remember that <a href="http://www.sqlskills.com/BLOGS/PAUL/post/Survey-what-is-the-highest-wait-on-your-system.aspx">Wait Stats survey</a> that Paul Randal ( <a href="http://www.sqlskills.com/blogs/paul/">blog</a> | <a href="http://twitter.com/PaulRandal">twitter</a> ) did a little while ago?  Well, we have several hundred SQL instances where I work and I wanted to be able to send Paul results from a large number of those servers. The thing is I didn&#8217;t want to have to actually login to each instance, run the query, save off the results, then repeat over and over again.  So I came up with this <a href="https://mail.ex1.secureserver.net/owa/redir.aspx?C=726ddb72560545c4b9cd539d1a20de03&amp;URL=http%3a%2f%2fsqlvariant.com%2fwordpress%2findex.php%2f2010%2f11%2fget-answers-for-paul-randals-survey-fast%2f">post</a>.  You can do the same to gather info multiple instances/databases in your environment.  It’s pretty straight-forward and very similar to the CSV example above but with a small pair of changes.  We need the two scripts that I mentioned in the other posts:  Chad Miller’s (<a href="http://sev17.com/">Blog</a>|<a href="http://www.twitter.com/cmille19">Twitter</a>)  <a href="http://gallery.technet.microsoft.com/ScriptCenter/en-us/7985b7ef-ed89-4dfd-b02a-433cc4e30894"><strong>invoke-sqlcmd2 </strong></a>and <a href="http://gallery.technet.microsoft.com/ScriptCenter/en-us/2fdeaf8d-b164-411c-9483-99413d6053ae"><strong>Write-DataTable</strong> </a>functions.  Once we have those loaded (and hopefully their in our <a href="http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-4/">profile</a> by now <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/wlEmoticon-winkingsmile1.png" alt="Winking smile" />) we’re off to the races being able to write information from multiple databases back into a single database.</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 226px;"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$db</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">" SELECT name FROM sys.databases WHERE owner_sid !=0x01"</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #8a2be2;">Win7NetBook</span><span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #ff4500;">$dt</span><span style="color: #a9a9a9;">=</span><span style="color: #0000ff;">invoke-sqlcmd<span style="background-color: #ffff00;"><strong>2</strong></span></span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">" SELECT DB_NAME(db_id()) AS 'DatabaseName', * FROM sysfiles"</span> <span style="color: #000080;">-ServerInstance</span>  <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span><span style="background-color: #ffff00;"> <span style="color: #000080;">-As</span> <span style="color: #8b0000;">'DataTable'</span></span>
<span style="color: #0000ff;">Write-DataTable</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">CentralInfo</span> <span style="color: #000080;">-TableName</span> <span style="color: #8a2be2;">dbFileName</span> <span style="color: #000080;">-Data</span> <span style="color: #ff4500;">$dt</span>
<span style="color: #000000;">}</span></pre>
<p>Here&#8217;s the SQL code to create that table so that you can test it out:</p>
<p><code style="font-size: 12px;"><span style="color: blue;">CREATE TABLE </span><span style="color: black;">[dbo].[dbFileName]</span><span style="color: gray;">(<br />
</span><span style="color: black;">[DatabaseName] [nvarchar]</span><span style="color: gray;">(</span><span style="color: black;">128</span><span style="color: gray;">) NULL,<br />
</span><span style="color: black;">[fileid] [smallint] </span><span style="color: gray;">NULL,<br />
</span><span style="color: black;">[groupid] [smallint] </span><span style="color: gray;">NULL,<br />
</span><span style="color: black;">[size] [int] </span><span style="color: gray;">NOT NULL,<br />
</span><span style="color: black;">[maxsize] [int] </span><span style="color: gray;">NOT NULL,<br />
</span><span style="color: black;">[growth] [int] </span><span style="color: gray;">NOT NULL,<br />
</span><span style="color: black;">[status] [int] </span><span style="color: gray;">NULL,<br />
</span><span style="color: black;">[perf] [int] </span><span style="color: gray;">NULL,<br />
</span><span style="color: black;">[name] [sysname] </span><span style="color: gray;">NOT NULL,<br />
</span><span style="color: black;">[filename] [nvarchar]</span><span style="color: gray;">(</span><span style="color: black;">260</span><span style="color: gray;">) NOT NULL<br />
) </span><span style="color: blue;">ON </span><span style="color: black;">[PRIMARY]</span></code></p>
<h3><span style="color: #004080;"><span style="font-weight: bold;">Output to Email:</span></span></h3>
<p>Call me lazy but…</p>
<p>I put this <a href="http://sqlvariant.com/BlogSupport/Scripts/PowerShell/Send-WaitSurveyToPaulRandal.html">next script</a> together just to see if it could be done.  Going back to that Wait Stats Survey, if you read all the way to the end you&#8217;ll see I managed to get the collection process down to 3 lines.  The only thing is that you still had to do something to the result set to exclude your instance names for security, and then after that you still had to do the whole copy-paste thing.</p>
<p>To combat all that wasted time I came up with this script which will go ahead and enumerate the instances for you.  That way if for any reason Paul emailed you back and said &#8216;Holy Crap, how the hell did you manage to get that as your highest wait on Instnce #14?&#8217; you&#8217;d still be able to go back and figure out which server he was talking about.  Also, If you would still have the results around in case you wanted to be proactive and take a look yourself (but let&#8217;s not get too carried away).</p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 354px;"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$RegisteredSQLs</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #000080;">-recurse</span> <span style="color: #8a2be2;">SQLSERVER:\SQLRegistration\'Database Engine Server Group'\</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Mode</span> <span style="color: #a9a9a9;">-ne</span> <span style="color: #8b0000;">"d"</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #ff4500;">$dt</span><span style="color: #a9a9a9;">=</span><span style="color: #0000ff;">invoke-sqlcmd2</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-InputFile</span> <span style="color: #8a2be2;">./PaulAndGlensWaitQuery.sql</span> <span style="color: #000080;">-As</span> <span style="color: #8b0000;">'DataTable'</span>
<span style="color: #0000ff;">Write-DataTable</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8b0000;">"Win7NetBook"</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">CentralInfo</span> <span style="color: #000080;">-TableName</span> <span style="color: #8a2be2;">TopWaitTypes</span> <span style="color: #000080;">-Data</span> <span style="color: #ff4500;">$dt</span>
<span style="color: #000000;">}</span>            

<span style="color: #ff4500;">$MultipleResults</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Invoke-Sqlcmd2</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8b0000;">"Win7NetBook"</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">CentralInfo</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">"SELECT DENSE_RANK() OVER (ORDER BY [InstanceName]) AS 'SQLInstance' ,[WaitType] ,[Wait_S] ,[Resource_S] ,[Signal_S] ,[WaitCount] ,[Percentage] FROM [CentralInfo].[dbo].[TopWaitTypes] ORDER BY SQLInstance, Percentage"</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">ConvertTo-Html</span> <span style="color: #000080;">-Property</span> <span style="color: #8a2be2;">SQLInstance</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">WaitType</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Wait_S</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Resource_S</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Signal_S</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">WaitCount</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Percentage</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Out-String</span><span style="color: #000000;">;</span>
<span style="color: #0000ff;">Send-MailMessage</span> <span style="color: #000080;">-To</span> <span style="color: #8a2be2;">paul@SQLskills.com</span> <span style="color: #000080;">-Subject</span> <span style="color: #8b0000;">"Wait Stats Query Results"</span> –<span style="color: #000080;">From</span> <span style="color: #8a2be2;">YourEmailAddress@GoesHere.com</span> <span style="color: #000080;">-SmtpServer</span> <span style="color: #8a2be2;">smtp.SQLvariant.com</span> <span style="color: #000080;">-Body</span> <span style="color: #ff4500;">$MultipleResults</span> <span style="color: #000080;">-BodyAsHtml</span></pre>
<p>Finally, you know we could put that SELECT statement into a .sql file.  That would cut it back down to ~6 lines.  We might even be able to wrap the email portion into something a little smaller but considering all that this script does I think this is good enough.</p>
<p><strong>It’s Later</strong></p>
<blockquote><p>When I first tried to do something like this I was was shocked to find out that there is no –Append switch for Export-CSV.  I wasn’t very happy about that, I mean I couldn’t wrap my head around how you could leave something like that out.  This ranked right up there with <a href="http://thomaslarock.com/2010/05/utility-control-point/">finding out</a> <strong>Utility Control Point</strong> only worked for managing other SQL 2008 R2 instances.  Luckily my story ended much better Tom’s.  First I reached out to <strong>ScriptingGuys</strong> ( <a href="http://blogs.technet.com/b/heyscriptingguy">blog</a> | <a href="http://twitter.com/ScriptingGuys">twitter</a> ) to make sure that I wasn’t crazy.  Then I did all I could do, sulked and filed a <a href="https://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=525407&amp;wa=wsignin1.0">Connect Item</a>.  The following day I woke up to the sun was shining, the birds chirping, and a tweet from <strong>Dmitry</strong> freaking <strong>Sotnikov</strong> himself ( <a href="http://dmitrysotnikov.wordpress.com/">blog</a> | <a href="http://twitter.com/DSotnikov">twitter</a> ) telling me that he had gone ahead and <a href="http://dmitrysotnikov.wordpress.com/2010/01/19/export-csv-append/">fixed that</a> for me by building a proxy command.  (It’s a function and since functions out rank cmdlets in call order anyone can augment the PowerShell language by adding a proxy command.)</p>
<p>…  and THAT is why I love PowerShell.</p></blockquote>
<h3><span style="color: #004080;">Homework</span></h3>
<p>Use the 3 techniques we walked through to run sp_configure against as many instances as possible.  Save it to a text file, CSV, and a table.  You might even want to add a date column or something.  You could also try email the results to yourself.</p>
<p>Do Not spam Paul Randal!  I cleared the email script with Paul before I included it.  If you want to send Paul the wait stats results from your servers I recommend that you test it first by emailing it to yourself.  If it looks good you go ahead and send it but make sure to include your email address in the –From parameter.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/hpERtD4ohN8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-6/</feedburner:origLink></item>
		<item>
		<title>PowerShell Week at SQL University – Post 5</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/Z_r18LJ-dc8/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-5/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 04:51:23 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-5/</guid>
		<description><![CDATA[In the previous posts we’ve just been poking around with PowerShell and trying to make the examples something that actually means something to a SQL person whenever we ca.  There are quite a few more language constructs that we need to cover but we have enough info to start recouping the time we’ve already invested.  Now it’s time to do one of those tasks that I just love to do with PowerShell.  We’re going to loop.  And we’re going to loop in a way that’s far easier than in any part of the SQL language. We’re going to cover 3 different sources for our loop that are the most common for DBAs to use: table, text file, Registered Server/Central Management Server.  After that we’re going to do a double loop and then it’s time for you to find something to do with these. Text File In this chunk of code we’re just going to read from a simple text file from our local hard drive and then loop through the instances in that file one at a time.  You put one instance on each line of the text file.  Don&#8217;t put it in quotes unless you&#8217;re using a non-standard port number.  This is the easiest method because each &#8220;row&#8221; that comes out of the text file only has one property.  We&#8217;ll find out why that&#8217;s important in the next example.  In the meantime setup your text file and test it by running just this: Get-Content C:\PowerShell\AllInstances.txt. foreach ($Instance in Get-Content C:\PowerShell\AllInstances.txt) { $Instance; Invoke-Sqlcmd -ServerInstance $Instance -Database master -Query "SELECT object_name , counter_name , instance_name , cntr_value , cntr_type FROM sys.dm_os_performance_counters" }   Database Table/ Query In this example we could be reading rows out of a table or running a more complex query to determine the list of databases that we want to run out query against.  This may actually seem easier to most database people and it is.  We&#8217;ve got a centrally located table and we can just look at it and know that we can change the first query to select a list of databases from somewhere else.  But there&#8217;s a really important thing to know if you swap out the query.   This approach is sending one usable property (column) to the foreach loop and it&#8217;s called &#8220;name&#8221;.  If you change the query and the column ends up being called database_name, you&#8217;re going to have to change $($db.name) to be called $($db.database_name).  Otherwise you&#8217;re going to loose a lot of hair and get really ticked after about 20 minutes like I did! foreach ($db in invoke-sqlcmd -query "SELECT name  FROM sys.databases WHERE owner_sid !=0x01" -database master -serverinstance Win7NetBook ) {$db.name; Invoke-sqlcmd -Query 'SELECT *   FROM sys.dm_exec_procedure_stats' -ServerInstance  Win7NetBook -Database $($db.name) }   Registered Servers/ Central Management Server Before you get started looping through your Registered Servers you’ll need to run this: Import-Module Agent if you want to do this exact example.  What we’re looking for here is all the jobs that have failed in the last 3 days in our “QA” group of servers.  This example should be easy enough for everyone to tweak on their own.  If you get stuck just remember to do Get-Help -Full Set-AgentJobHistoryFilter (Huge thanks to Chad Miller for helping me put together this demo so that it would be a fast one to run!) $filter = Set-AgentJobHistoryFilter -startDate $(get-date).AddDays(-3) -endDate $(get-date) -outcome 'Failed' foreach ($RegisteredSQLs in dir -recurse SQLSERVER:\SQLRegistration\'Database Engine Server Group'\QA\ &#124; where {$_.Mode -ne "d"} ) { Get-AgentJobHistory $RegisteredSQLs.ServerName $filter &#124; where-object {$_.StepID -ne 0} }   Double Loop This has to be one of my favorite PowerShell scripts of all time (so far).  I had to run a query against every database in a group of over 10 servers.  I’ve changed this one around a little but I’m sure you’ll find a use for it!  (Think permissions.) foreach ($RegisteredSQLs in dir -recurse SQLSERVER:\SQLRegistration\'Database Engine Server Group'\QA\ &#124; where {$_.Mode -ne "d"} ) {     foreach ($DBName in invoke-sqlcmd -query "SELECT name   FROM sys.databases WHERE name in ('AdventureWorks', 'AdventureWorks2008', 'AdventureWorks2008R2', 'AdventureWorksDW' ) " -database master -serverinstance $RegisteredSQLs.ServerName )             {                     invoke-sqlcmd -query 'SELECT *         FROM sys.dm_db_index_usage_stats' -ServerInstance $RegisteredSQLs.ServerName -database $DBName.name             } #EndOfTheFoundDatabasesLoop } #EndOfTheRegisteredServerLoop   Homework Try out each of these methods and think up something you could use this for.  If you hit on something that save you some clicking around in SQL Management Studio please mention it in the comments.]]></description>
			<content:encoded><![CDATA[<p>In the previous posts we’ve just been poking around with PowerShell and trying to make the examples something that actually means something to a SQL person whenever we ca.  There are quite a few more language constructs that we need to cover but we have enough info to start recouping the time we’ve already invested.  Now it’s time to do one of those tasks that I just love to do with PowerShell.  We’re going to loop.  And we’re going to loop in a way that’s far easier than in any part of the SQL language.</p>
<p>We’re going to cover 3 different sources for our loop that are the most common for DBAs to use: <strong>table</strong>, <strong>text file</strong>, <strong>Registered Server</strong>/<strong>Central Management Server</strong>.  After that we’re going to do a double loop and then it’s time for you to find something to do with these.</p>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-latin;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;">Text File</span></span></span></h2>
<p>In this chunk of code we’re just going to read from a simple text file from our local hard drive and then loop through the instances in that file one at a time.  You put one instance on each line of the text file.  Don&#8217;t put it in quotes unless you&#8217;re using a non-standard port number.  This is the easiest method because each &#8220;row&#8221; that comes out of the text file only has one property.  We&#8217;ll find out why that&#8217;s important in the next example.  In the meantime setup your text file and test it by running just this: <span style="color: #0000ff;">Get-Content</span> <span style="color: #8a2be2;">C:\PowerShell\AllInstances.txt</span>.</p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$Instance</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">Get-Content</span> <span style="color: #8a2be2;">C:\PowerShell\AllInstances.txt</span><span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #ff4500;">$Instance</span><span style="color: #000000;">;</span>
<span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #ff4500;">$Instance</span> <span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">"</span><span style="color: #8b0000;">SELECT  object_name ,
        counter_name ,
        instance_name ,
        cntr_value ,
        cntr_type
  FROM sys.dm_os_performance_counters"</span>
<span style="color: #000000;">}</span></pre>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;"> </span></span></span></h2>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;">Database Table/ Query</span></span></span></h2>
<p><span style="color: #00008b;"><span style="color: #000000;">In this example we could be reading rows out of a table or running a more complex query to determine the list of databases that we want to run out query against.  This may actually seem easier to most database people and it is.  We&#8217;ve got a centrally located table and we can just look at it and know that we can change the first query to select a list of databases from somewhere else.  But there&#8217;s a really important thing to know if you swap out the query.   This approach is sending one usable property (column) to the foreach loop and it&#8217;s called &#8220;name&#8221;.  If you change the query and the column ends up being called database_name, you&#8217;re going to have to change $(<span style="color: #ff0000;">$db</span>.name) to be called $(<span style="color: #ff0000;">$db</span>.database_name).  Otherwise you&#8217;re going to loose a lot of hair and get really ticked after about 20 minutes like I did!<br />
</span></span></p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$db</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">"SELECT name  FROM sys.databases WHERE owner_sid !=0x01" </span><span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span><span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span><span style="color: #000000;">;</span>
<span style="color: #0000ff;">Invoke-sqlcmd</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">'SELECT *
  FROM sys.dm_exec_procedure_stats'</span> <span style="color: #000080;">-ServerInstance</span>  <span style="color: #8a2be2;">Win7NetBook</span> <span style="color: #000080;">-Database</span> <span style="color: #000000;">$(</span><span style="color: #ff4500;">$db</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span><span style="color: #000000;">)</span>
<span style="color: #000000;">}</span></pre>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;"> </span></span></span></h2>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;">Registered Servers/ Central Management Server</span></span></span></h2>
<p>Before you get started looping through your Registered Servers you’ll need to run this: <span style="font-family: Lucida Console;"><strong><span style="line-height: 12pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa;"><span style="color: #0000ff;"><span style="font-size: 10pt;">Import-Module</span></span></span><span style="line-height: 12pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa;"><span style="font-size: 10pt;"> </span><span style="color: #8a2be2; font-size: 10pt;">Agent</span></span></strong></span> if you want to do this exact example.  What we’re looking for here is all the jobs that have failed in the last 3 days in our “QA” group of servers.  This example should be easy enough for everyone to tweak on their own.  If you get stuck just remember to do <span style="color: #0000ff;">Get-Help</span> -Full <span style="color: #8a2be2;">Set-AgentJobHistoryFilter</span><br />
(Huge thanks to Chad Miller for helping me put together this demo so that it would be a fast one to run!)</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$filter</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Set-AgentJobHistoryFilter</span> <span style="color: #000080;">-startDate</span> <span style="color: #000000;">$(</span><span style="color: #0000ff;">get-date</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">AddDays</span><span style="color: #000000;">(</span><span style="color: #800080;">-3</span><span style="color: #000000;">)</span> <span style="color: #000080;">-endDate</span> <span style="color: #000000;">$(</span><span style="color: #0000ff;">get-date</span><span style="color: #000000;">)</span> <span style="color: #000080;">-outcome</span> <span style="color: #8b0000;">'Failed'</span>

<span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$RegisteredSQLs</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #000080;">-recurse</span> <span style="color: #8a2be2;">SQLSERVER:\SQLRegistration\'Database Engine Server Group'\QA\</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Mode</span> <span style="color: #a9a9a9;">-ne</span> <span style="color: #8b0000;">"d"</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
<span style="color: #0000ff;">Get-AgentJobHistory</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span> <span style="color: #ff4500;">$filter</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where-object</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">StepID</span> <span style="color: #a9a9a9;">-ne</span> <span style="color: #800080;">0</span><span style="color: #000000;">}</span>
<span style="color: #000000;">}</span></pre>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;"> </span></span></span></h2>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;">Double Loop</span></span></span></h2>
<p><span style="color: #00008b;"><span style="color: #000000;">This has to be one of my <strong>favorite PowerShell scripts of all time</strong> (so far).  I had to run a query against every database in a group of over 10 servers.  I’ve changed this one around a little but I’m sure you’ll find a use for it!  (Think permissions.)</span></span></p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$RegisteredSQLs</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">dir</span> <span style="color: #000080;">-recurse</span> <span style="color: #8a2be2;">SQLSERVER:\SQLRegistration\'Database Engine Server Group'\QA\</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">where</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Mode</span> <span style="color: #a9a9a9;">-ne</span> <span style="color: #8b0000;">"d"</span><span style="color: #000000;">}</span> <span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
    <span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$DBName</span> <span style="color: #00008b;">in</span> <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">"SELECT name
  FROM sys.databases WHERE name in ('AdventureWorks',
            'AdventureWorks2008',
            'AdventureWorks2008R2',
            'AdventureWorksDW'
            ) "</span> <span style="color: #000080;">-database</span> <span style="color: #8a2be2;">master</span> <span style="color: #000080;">-serverinstance</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span> <span style="color: #000000;">)</span>
            <span style="color: #000000;">{</span>
                    <span style="color: #0000ff;">invoke-sqlcmd</span> <span style="color: #000080;">-query</span> <span style="color: #8b0000;">'SELECT *
        FROM sys.dm_db_index_usage_stats'</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #ff4500;">$RegisteredSQLs</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ServerName</span> <span style="color: #000080;">-database</span> <span style="color: #ff4500;">$DBName</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span>
            <span style="color: #000000;">}</span> <span style="color: #006400;">#EndOfTheFoundDatabasesLoop</span>
<span style="color: #000000;">}</span> <span style="color: #006400;">#EndOfTheRegisteredServerLoop</span></pre>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;"> </span></span></span></h2>
<h2 style="margin: 6pt 0in 0pt;"><span style="mso-bidi-font-size: 11.0pt;"><span style="color: #498d49; font-size: 14pt;"><span style="font-weight: bold;">Homework</span></span></span></h2>
<p>Try out each of these methods and think up something you could use this for.  If you hit on something that save you some clicking around in SQL Management Studio please mention it in the comments.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/Z_r18LJ-dc8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-5/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-5/</feedburner:origLink></item>
		<item>
		<title>PowerShell Week at SQL University – Post 4</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/2GCoJ-tfBVM/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-4/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 16:23:37 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[Profile]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL University]]></category>
		<category><![CDATA[Syndicated]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-4/</guid>
		<description><![CDATA[Recap So far we’ve walked though how to turn on PowerShell and add modules, adding SQL Server 2008 snapins and using PowerShell variables, what cmdlets and functions are, what providers are and how to work with methods &#38; properties. Profiles Today we focus on load things in our profile so that they are always available in PowerShell.  First, some basics: What is a Profile?  A profile is nothing more than a PowerShell script that gets run as soon as you open up a given PowerShell window. Why would we want to do this?  I use PowerShell almost exclusively for automating work with my SQL Servers.  When I’m ready to do something I don’t want to start by reloading the same toolset every time I open it. I want to click the icon and be ready to go.  The profile saves me from this repetitive loading.  I update my profile as I find cool new scripts that I want to add. You are not limited to using a single profile in PowerShell.  Personally, I use one of three profiles depending on the task at hand.  Here is how that works. I use the PowerShell ISE or other third party products as my primary way of writing PowerShell scripts (.ps1) and rarely use the “console.”   I only use the console if I need to troubleshoot something that might have to do with STA/MTA.  When I open up the PowerShell ISE it’s uses it’s own profile CurrentUserCurrentHost that is stored in C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1 (picture-right).  Inside of that file on my machine it currently looks like this: import-module ISEPack cd C:\Users\Aaron\Documents\PoSh\Load . ./invoke-sqlcmd2.ps1 . ./Write-DataTable.ps1 . ./Out-DataTable.ps1 . ./Add-SqlTable.ps1 . ./Export-CSV-Append.ps1 . ./invoke-sqlcommand.ps1 . C:\Users\Aaron\Documents\PoSh\Tasks\Get-DisksSpace.ps1 cd c:\temp\ Whatever is in this file only gets loaded into my session when I open the ISE.  Nothing above gets run when I open up the console.  These are items I use in ISE, but not in the console PowerShell window. There are items I use in both ISE and the console.  These items live in a “super profile” of sorts since I want these items no matter how I access PowerShell CurrentUserAllHosts (which is located in C:\Users\USERNAME\Documents\WindowsPowerShell\profile.ps1). Profile.ps1 (picture-center) gets run every time I open up any PowerShell &#8220;host&#8221; including 3rd party tools.  This also includes the SQLPS host which may cause errors messages to appear when you open it or run a SQL Agent Job.  These error messages don&#8217;t impact a PowerShell step in a SQL Agent Job from running. Here’s what I have inside of my Profile.ps1 file. Add-PSSnapin SqlServerCmdletSnapin100 Add-PSSnapin SqlServerProviderSnapin100 Import-Module SQLServer Whenever I open the ISE both the Microsoft.PowerShellISE_profile.ps1 and the Profile.ps1 scripts get run. PowerShell.exe (the little blue &#8220;host&#8221;) has it&#8217;s very own CurrentUserCurrentHost profile that it loads.  That&#8217;s the exact same name as the profile that we talked about the ISE loading so does that mean that it&#8217;s loading that same file?  No.  Each one is configured to load it&#8217;s own CurrentUserCurrentHost from a different location.  So if there are items I want in console world only I have a place to store them thanks to C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.  Since I rarely use the console my profile there sat empty until recently.  I only added items after I spotted a post by Oisin Grehan ( blog &#124; twitter ) on Implementing a Matrix-Style Console Screen Saver and I HAD to try it.  This only works in the console and not in the ISE so it made my console profile the perfect place for implementing this.  Now my PowerShell_profile.ps1 file (picture-left) looks like this: Import-Module screensaver set-screensavertimeout (new-timespan -minutes 5) enable-screensaver Start-ScreenSaver To edit one of the profiles that only load for the console or the ISE all you have to do is open them up and run notepad $profile.  It will figure out which file is the right one for that environment and open it for you.  To edit the profile that is run in every PowerShell environment just run notepad $profile.CurrentUserAllHosts.  If your WindowsPowerShell directory isn&#8217;t there it will not automatically create that for you and you will get an error message stating that it &#8220;can&#8217;t find the specified path&#8220;.  I&#8217;ve written a little script to check for that and create one for you if it&#8217;s not already there: $myPowerShell = $HOME $myPowerShell +="\Documents\WindowsPowerShell" if ((Test-Path $myPowerShell) -eq "true") {"$myPowerShell is already there mate"} else { "you need to make one" mkdir $myPowerShell } Homework Assignment: Setup one of your profiles to at least have one of the modules from the SQLPSX project and the SQL Server Snapins loaded up every time you start up the PowerShell ISE. Which profile to use is completely up to you.  Feel free to play around with your choices.  Optionally you can also include the Get-DisksSpace function like I do; but you don’t have to. Let me know how this goes for you by dropping a note it the comments.  In tomorrow’s post we are going to work with multiple SQL Servers so you’ll need these things up and running for that. If you’re confused by where your files are you can just run this script that I lifted off of the HeyScriptingGuys site to have it tell you where all of the profiles for your session have been loaded from.  Keep in mind that we’re not touching the ones in the Windows directory. $profile &#124; Get-Member -MemberType note* &#124; Format-Table -Wrap -AutoSize -Property name, @{ Label=&#8220;Path&#8221;; Expression={$_.definition -replace &#8220;System.String&#8221;,&#8220;&#8221;} } In Case you would like more to play with&#8230; There is a lot more that can be done with PowerShell Profiles but these are the basics you need to get up and running. If you want to dive deeper check out these posts over on the Hey Scripting Guy Blog.  Go here to download the SQLServer or ISEPack modules; they are both part of larger projects.  If you&#8217;d like some of the scripts that I reference in my profile you can grab the Get-DisksSpace one here and I&#8217;ll be blogging about the rest later this week. Be Advised: Everything that you put into you profile eats up RAM.  Thankfully most scripts are only a few kilobytes.  Keep in mind that the more items you add into your profile the longer that it is going to take to load. In case you’re wondering if that “Matrix Style Console Screen Saver” is worth having around, here is what it looks like after a few minutes: That’s all that I’ve got for you today, see you back tomorrow!]]></description>
			<content:encoded><![CDATA[<h3 style="line-height: 13pt; margin: 10pt 0in 0pt;"><span style="font-family: Cambria;"><span style="color: #4f81bd; font-size: 11pt;"><span style="font-weight: bold;">Recap</span></span></span></h3>
<p>So far we’ve walked though how to turn on PowerShell and add <a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-0/">modules</a>, adding SQL Server 2008 snapins and using PowerShell <a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-1/">variables</a>, what cmdlets and functions <a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-2/">are</a>, what providers are and how to work with methods &amp; <a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-3/">properties</a>.</p>
<h2 style="line-height: 13pt; margin: 10pt 0in 0pt;"><span style="font-family: Cambria;"><span style="color: #4f81bd; font-size: 11pt;"><span style="font-weight: bold;">Profiles</span></span></span></h2>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/PowerShellProfiles.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" title="PowerShellProfiles" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/PowerShellProfiles_thumb.png" border="0" alt="PowerShellProfiles" width="405" height="160" align="right" /></a>Today we focus on load things in our <strong>profile</strong> so that they are always available in PowerShell.  First, some basics:</p>
<p><em><strong>What is a Profile?</strong></em>  A profile is nothing more than a PowerShell script that gets run as soon as you open up a given PowerShell window.</p>
<p><em><strong>Why would we want to do this?</strong></em>  I use PowerShell almost exclusively for automating work with my SQL Servers.  When I’m ready to do something I don’t want to start by reloading the same toolset every time I open it. I want to <span style="text-decoration: underline;">click the icon and be ready to go</span>.  The profile saves me from this repetitive loading.  I update my profile as I find cool new scripts that I want to add.</p>
<p>You are not limited to using a single profile in PowerShell.  Personally, I use one of three profiles depending on the task at hand.  Here is how that works. I use the <strong>PowerShell ISE</strong> or other third party products as my primary way of writing PowerShell scripts (.ps1) and rarely use the “<strong>console.</strong>”   I only use the console if I need to troubleshoot something that might have to do with STA/MTA. </p>
<p>When I open up the <strong>PowerShell ISE</strong> it’s uses it’s own profile <span style="color: #0000ff;"><strong>CurrentUserCurrentHost</strong> <span style="color: #000000;">that is stored in</span> C:\Users\USERNAME\Documents\WindowsPowerShell\<strong>Microsoft.PowerShellISE_profile.ps1</strong></span> (<strong>picture-right</strong>).  Inside of that file on my machine it currently looks like this:</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff;">import-module</span> <span style="color: #8a2be2;">ISEPack</span>
<span style="color: #0000ff;">cd</span> <span style="color: #8a2be2;">C:\Users\Aaron\Documents\PoSh\Load</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">./invoke-sqlcmd2.ps1</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">./Write-DataTable.ps1</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">./Out-DataTable.ps1</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">./Add-SqlTable.ps1</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">./Export-CSV-Append.ps1</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">./invoke-sqlcommand.ps1</span>
<span style="color: #a9a9a9;">.</span> <span style="color: #0000ff;">C:\Users\Aaron\Documents\PoSh\Tasks\Get-DisksSpace.ps1</span>
<span style="color: #0000ff;">cd</span> <span style="color: #8a2be2;">c:\temp\</span></pre>
<p>Whatever is in this file <strong>only</strong> gets loaded into my session when I open the <strong>ISE</strong>.  Nothing above gets run when I open up the console.  These are items I use in ISE, but not in the console PowerShell window.</p>
<p>There are items I use in both ISE and the console.  These items live in a “super profile” of sorts since I want these items no matter how I access PowerShell <span style="color: #0000ff;"><strong>CurrentUser<span style="text-decoration: underline;">AllHosts</span></strong> (<span style="color: #000000;">which is located in</span> C:\Users\USERNAME\Documents\WindowsPowerShell\<strong>profile.ps1</strong></span>). <strong><span style="color: #0000ff;">Profile.ps1</span></strong> (<strong>picture-center</strong>) gets run every time I open up <strong><span style="text-decoration: underline;">any</span></strong> PowerShell &#8220;host&#8221; including 3rd party tools.  This also includes the SQLPS host which may cause errors messages to appear when you open it or run a SQL Agent Job.  These error messages don&#8217;t impact a PowerShell step in a SQL Agent Job from running.</p>
<p>Here’s what I have inside of my <strong><span style="color: #0000ff;">Profile.ps1</span></strong> file.</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff;">Add-PSSnapin</span> <span style="color: #8a2be2;">SqlServerCmdletSnapin100</span>
<span style="color: #0000ff;">Add-PSSnapin</span> <span style="color: #8a2be2;">SqlServerProviderSnapin100</span>
<span style="color: #0000ff;">Import-Module</span> <span style="color: #8a2be2;">SQLServer</span></pre>
<p>Whenever I open the ISE both the <span style="color: #0000ff;"><strong>Microsoft.PowerShellISE_profile.ps1</strong></span> and the <strong><span style="color: #0000ff;">Profile.ps1</span></strong> scripts get run.</p>
<p>PowerShell.exe (the little blue &#8220;host&#8221;) has it&#8217;s very own <strong><span style="color: #0000ff;">CurrentUserCurrentHost</span></strong> profile that it loads.  That&#8217;s the exact same name as the profile that we talked about the ISE loading so does that mean that it&#8217;s loading that same file?  No.  Each one is configured to load it&#8217;s own CurrentUserCurrentHost from a different location.  So if there are items I want in console world only I have a place to store them thanks to <span style="color: #0000ff;">C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.</span>  Since I rarely use the console my profile there sat empty until recently.  I only added items after I spotted a post by Oisin Grehan ( <a href="http://www.nivot.org/">blog</a> | <a href="http://twitter.com/oising">twitter</a> ) on <a href="http://www.nivot.org/2010/12/18/PowerShell20ImplementingAMatrixStyleConsoleScreenSaver.aspx">Implementing a Matrix-Style Console Screen Saver</a> and I <span style="text-decoration: underline;">HAD</span> to try it.  This only works in the console and not in the ISE so it made my console profile the perfect place for implementing this.  Now my <span style="color: #0000ff;">PowerShell_profile.ps1</span> file (<strong>picture-left</strong>) looks like this:</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff;">Import-Module</span> <span style="color: #8a2be2;">screensaver</span>
<span style="color: #0000ff;">set-screensavertimeout</span> <span style="color: #000000;">(</span><span style="color: #0000ff;">new-timespan</span> <span style="color: #000080;">-minutes</span> <span style="color: #800080;">5</span><span style="color: #000000;">)</span>
<span style="color: #0000ff;">enable-screensaver</span>
<span style="color: #0000ff;">Start-ScreenSaver</span></pre>
<p>To edit one of the profiles that only load for the console or the ISE all you have to do is open them up and run <span style="font-family: lucida console;"><span style="font-size: x-small;"><span style="line-height: 14pt; mso-bidi-font-family: &amp;amp;amp;"><span style="color: #0000ff;">notepad</span></span><span style="line-height: 14pt; mso-bidi-font-family: &amp;amp;amp;"> <span style="color: #ff4500;">$profile</span></span></span></span>.  It will figure out which file is the right one for that environment and open it for you.  To edit the profile that is run in every PowerShell environment just run <span style="font-family: lucida console;"><span style="font-size: x-small;"><span style="line-height: 13pt; mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="color: #0000ff;">notepad</span></span><span style="line-height: 13pt; mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"> <span style="color: #ff4500;">$profile</span><span style="color: #a9a9a9;">.</span>CurrentUserAllHosts</span></span></span>.  If your WindowsPowerShell directory isn&#8217;t there it <span style="text-decoration: underline;">will not</span> automatically create that for you and you will get an error message stating that it &#8220;<em>can&#8217;t find the specified path</em>&#8220;.  I&#8217;ve written a little script to check for that and create one for you if it&#8217;s not already there:</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$myPowerShell</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$HOME</span>
<span style="color: #ff4500;">$myPowerShell</span> <span style="color: #a9a9a9;">+=</span><span style="color: #8b0000;">"\Documents\WindowsPowerShell"</span>
<span style="color: #00008b;">if</span> <span style="color: #000000;">(</span><span style="color: #000000;">(</span><span style="color: #0000ff;">Test-Path</span> <span style="color: #ff4500;">$myPowerShell</span><span style="color: #000000;">)</span> <span style="color: #a9a9a9;">-eq</span> <span style="color: #8b0000;">"true"</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span><span style="color: #8b0000;">"$myPowerShell is already there mate"</span><span style="color: #000000;">}</span>
<span style="color: #00008b;">else</span> <span style="color: #000000;">{</span> <span style="color: #8b0000;">"you need to make one"</span>
<span style="color: #0000ff;">mkdir</span> <span style="color: #ff4500;">$myPowerShell</span>  <span style="color: #000000;">}</span></pre>
<h2 style="line-height: 15pt; margin: 10pt 0in 0pt;"><span style="font-family: Cambria;"><span style="color: #4f81bd; font-size: 13pt;"><span style="font-weight: bold;">Homework Assignment:</span></span></span></h2>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt;"><strong>Setup one of your profiles</strong> to at least have one of the modules from the <a href="http://sqlpsx.codeplex.com/"><strong>SQLPSX project</strong></a> and the <strong>SQL Server Snapins</strong> loaded up every time you start up the PowerShell ISE.<span style="mso-spacerun: yes;"> </span>Which profile to use is completely up to you.<span style="mso-spacerun: yes;">  </span>Feel free to play around with your choices.<span style="mso-spacerun: yes;">  </span>Optionally you can also include the Get-DisksSpace function like I do; but you don’t have to.</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt;">Let me know how this goes for you by <strong>dropping a note it the comments</strong>.<span style="mso-spacerun: yes;">  </span>In tomorrow’s post we are going to work with multiple SQL Servers so you’ll need these things up and running for that.</p>
<p class="MsoNormal" style="line-height: 13pt; margin: 0in 0in 10pt;"><strong><em>If you’re confused</em></strong> by where your files are you can just run this script that I lifted off of the <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/05/how-to-create-a-customizable-profile-for-the-powershell-ise.aspx"><span style="color: #800080;">HeyScriptingGuys</span></a> site to have it tell you where all of the profiles for your session have been loaded from.<span style="mso-spacerun: yes;">  </span>Keep in mind that we’re not touching the ones in the Windows directory.</p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Lucida Console;"><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="color: #ff4500;"><span style="font-size: 10pt;">$profile</span></span></span><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="font-size: 10pt;"> <span><span style="color: #a9a9a9;">|</span></span></span><span style="mso-spacerun: yes;"><span style="font-size: 10pt;"> </span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Lucida Console;"><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="color: #0000ff;"><span style="font-size: 10pt;">Get-Member</span></span></span><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="font-size: 10pt;"> <span><span style="color: #000080;">-MemberType</span></span> <span><span style="color: #8a2be2;">note*</span></span> <span><span style="color: #a9a9a9;">|</span></span></span><span style="mso-spacerun: yes;"><span style="font-size: 10pt;"> </span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Lucida Console;"><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="color: #0000ff;"><span style="font-size: 10pt;">Format-Table</span></span></span><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="font-size: 10pt;"> <span><span style="color: #000080;">-Wrap</span></span> <span><span style="color: #000080;">-AutoSize</span></span> <span><span style="color: #000080;">-Property</span></span> <span><span style="color: #8a2be2;">name</span></span><span><span style="color: #a9a9a9;">,</span></span></span><span style="mso-spacerun: yes;"><span style="font-size: 10pt;"> </span></span></span></span></p>
<p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-bidi-font-family: &amp;amp;amp; mso-bidi-font-size: 12.0pt;"><span style="font-family: Lucida Console;"><span style="font-size: 10pt;"><span>@{</span> <span>Label</span><span><span style="color: #a9a9a9;">=</span></span><span><span style="color: #8b0000;">&#8220;Path&#8221;</span></span><span>;</span> <span>Expression</span><span><span style="color: #a9a9a9;">=</span></span><span>{</span><span><span style="color: #ff4500;">$_</span></span><span><span style="color: #a9a9a9;">.</span></span><span>definition</span> <span><span style="color: #a9a9a9;">-replace</span></span> <span><span style="color: #8b0000;">&#8220;System.String&#8221;</span></span><span><span style="color: #a9a9a9;">,</span></span><span><span style="color: #8b0000;">&#8220;&#8221;</span></span><span>}</span> <span>}</span> </span></span></span></p>
<p><a href="http://sqlchicken.com/SQL-University"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" title="SQL University" src="http://sqlchicken.com/wp-content/uploads/2010/11/SQL_University_Web1.png" border="0" alt="PowerShellProfiles" width="150" height="120" align="right" /></a></p>
<h2 style="line-height: 15pt; margin: 10pt 0in 0pt;"><span style="font-family: Cambria;"><span style="color: #4f81bd; font-size: 13pt;"><span style="font-weight: bold;">In Case you would like more to play with&#8230;</span></span></span></h2>
<p>There is a lot more that can be done with PowerShell Profiles but these are the basics you need to get up and running. If you want to dive deeper check out <a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/profiles/">these posts</a> over on the Hey Scripting Guy Blog.  Go here to download the <a href="http://sqlpsx.codeplex.com/">SQLServer</a> or <a href="http://code.msdn.microsoft.com/PowerShellPack">ISEPack</a> modules; they are both part of larger projects.  If you&#8217;d like some of the scripts that I reference in my profile you can grab the <a href="http://sqlvariant.com/wordpress/index.php/2010/11/quick-blog-powershell-disk-and-mountpoint-check/">Get-DisksSpace</a> one here and I&#8217;ll be blogging about the rest later this week.</p>
<p><span style="color: #0000ff;"><strong><span style="color: #000080;">Be Advised:</span></strong></span></p>
<p>Everything that you put into you profile eats up RAM.  Thankfully most scripts are only a few kilobytes.  Keep in mind that the more items you add into your profile the longer that it is going to take to load.</p>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image_thumb3.png" border="0" alt="image" width="453" height="292" align="right" /></a>In case you’re wondering if that “Matrix Style Console Screen Saver” is worth having around, here is what it looks like after a few minutes:</p>
<p>That’s all that I’ve got for you today, see you back tomorrow!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/2GCoJ-tfBVM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/powershell-week-at-sql-university-post-4/</feedburner:origLink></item>
		<item>
		<title>SQL Smackdown: SSIS vs. PowerShell</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/2wwPABFjVO4/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/sql-smackdown-ssis-vs-powershell/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 14:50:08 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Saturday]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=1943</guid>
		<description><![CDATA[I’ll be presenting with Mike Davis ( blog &#124; twitter ) at SQL Saturday #62 this weekend.  I’ll be presenting on a topic that is very near and dear to my heart: Not using SSIS!  And Mike, well lets face it.  I know Mike’s written a book or two on SSIS but about all that Mike will be doing is showing everyone why I love PowerShell so much.  I hear he even picked up a brand new laptop so that BIDS wouldn’t slow him down as much.  I’ll be bringing my old Netbook running multiple instances of SQL Server.  $5 says I still complete my demos in half the time as Mike’s. Mike says that we’re going to “Square off” but I heard the new SSIS has pretty new rounded corners.  I don’t know about you but that a feature that I’ve been waiting a loooong time for.  I bet he’s going to be doing a lot of talking about what might be in the Denali version of SSIS but I’ll be showing you what 4 or 5 lines of PowerShell can do for you today!  So if you’re looking for something to do around 2:45 Saturday afternoon come see what PowerShell can do for you!]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/SQLsmackdown.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" title="SQLsmackdown" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/SQLsmackdown_thumb.jpg" border="0" alt="SQLsmackdown" width="244" height="158" align="right" /></a>I’ll be presenting with Mike Davis ( <a href="http://www.bidn.com/blogs/MikeDavis/">blog</a> | <a href="http://www.twitter.com/MikeDavisSQL">twitter</a> ) at SQL Saturday #62 this weekend.  I’ll be presenting on a topic that is very near and dear to my heart: <strong>Not using SSIS</strong>!  And Mike, well lets face it.  I know Mike’s written a <a href="http://www.amazon.com/Knights-24-Hour-Trainer-Integration-Programmer/dp/0470496924/ref=sr_1_1?ie=UTF8&amp;qid=1294929975&amp;sr=8-1">book or two on SSIS</a> but about all that Mike will be doing is showing everyone why I love PowerShell so much.  I hear he even picked up a brand new laptop so that BIDS wouldn’t slow him down as much.  I’ll be bringing my old Netbook running multiple instances of SQL Server.  $5 says I still complete my demos in <strong>half</strong> the time as Mike’s.</p>
<p>Mike says that we’re going to “<a href="http://www.bidn.com/blogs/MikeDavis/ssis/1373/sql-smackdown-at-sql-saturday-tampa-2011">Square off</a>” but I heard the new SSIS has pretty new rounded corners.  I don’t know about you but that a feature that I’ve been waiting a loooong time for.  I bet he’s going to be doing a lot of talking about what <em><span style="text-decoration: underline;">might be</span></em> in the <strong>Denali</strong> version of SSIS but I’ll be showing you what 4 or 5 lines of <strong>PowerShell</strong> can do for you <span style="text-decoration: underline;">today</span>!  So if you’re looking for something to do around 2:45 Saturday afternoon come see what PowerShell can do for you!</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/2wwPABFjVO4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/sql-smackdown-ssis-vs-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/sql-smackdown-ssis-vs-powershell/</feedburner:origLink></item>
		<item>
		<title>Is the Connect Feed for SQL Server in Your Reader?</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/7FPJef9fRFI/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/is-the-connect-feed-for-sql-server-in-your-reader/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 15:08:56 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Connect]]></category>
		<category><![CDATA[Out-GridView]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/01/is-the-connect-feed-for-sql-server-in-your-reader/</guid>
		<description><![CDATA[Last week Nicolas Cain ( blog &#124; twitter ) Rob Farley ( blog &#124; twitter ) Aaron Bertrand ( blog &#124; twitter ) and I were all working together on a small skunk-works project to read in all of of the items on the SQL-Connect website (more in that project in a later post).  A few hours into this process I realized “hey, I don’t even have this RSS feed in my Reader!”  I’m not sure why I didn’t; maybe I was lulled into safety by Aaron Bertrand’s “Connect Digests” but unfortunately he doesn’t do those any more. So I just wanted to encourage everyone who makes their living off of SQL Server to take a minute to add these two RSS feeds to your favorite feed-reader.  https://connect.microsoft.com/rss/68/RecentFeedbackForConnection.xml https://connect.microsoft.com/rss/68/RecentlyModifiedFeedbackForConnection.xml If you haven’t been on Connect for a while and wonder what’s out there, well I’ve got a PowerShell script for you   Invoke-Sqlcmd -ServerInstance denali.db.5026258.hostedresource.com ` -Database denali -Username denaliconnect -Password Wide0pen -Query " SELECT ID , Title , ItemStatus , UpVoteCount , DownVoteCount , ItemDescription , Author , Modified , ValidationCount , WorkAroundCount , URL , OpenedDate FROM denali.dbo.ConnectItems" &#124; out-gridview OK, you can totally take that login info and use your SQL Management Studio to connect to this database too but I wanted to show you a REALLY cool use for the Out-GridView command.  When run the PowerShell script and the window pops up Just Click on + Add Criteria &#62; ItemDescription &#62; Add. Like this: Then just type in a search term like “SSIS” and see what you get back… Rob has also put together a way to search the data that is much better and where we hope to ultimately go with it.  Again, that’s all for another post.]]></description>
			<content:encoded><![CDATA[<p>Last week <strong>Nicolas Cain</strong> ( <a href="http://www.englishtosql.com/">blog</a> | <a href="http://twitter.com/anonythemouse">twitter</a> ) Rob Farley ( <a href="http://sqlblog.com/blogs/rob_farley">blog</a> | <a href="http://www.twitter.com/rob_farley">twitter</a> ) Aaron Bertrand ( <a href="http://sqlblog.com/blogs/aaron_bertrand/default.aspx">blog</a> | <a href="http://twitter.com/AaronBertrand">twitter</a> ) and I were all working together on a <a href="http://www.englishtosql.com/english-to-sql-blog/2011/1/5/loading-microsoft-connect-items-to-a-databaseintro.html">small skunk-works project</a> to read in all of of the items on the <a href="https://connect.microsoft.com/SQLServer">SQL-Connect website</a> (more in that project in a later post).  A few hours into this process I realized <strong>“hey, I don’t even have this RSS feed in my Reader!”</strong>  I’m not sure why I didn’t; maybe I was lulled into safety by Aaron Bertrand’s “Connect Digests” but unfortunately he doesn’t do those any more. <img class="wlEmoticon wlEmoticon-cryingface" style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/wlEmoticon-cryingface.png" alt="Crying face" /></p>
<h3>So I just wanted to encourage everyone who makes their living off of SQL Server to take a minute to add these two RSS feeds to your favorite feed-reader. </h3>
<p><a title="https://connect.microsoft.com/rss/68/RecentFeedbackForConnection.xml" href="https://connect.microsoft.com/rss/68/RecentFeedbackForConnection.xml">https://connect.microsoft.com/rss/68/RecentFeedbackForConnection.xml</a></p>
<p><a title="https://connect.microsoft.com/rss/68/RecentlyModifiedFeedbackForConnection.xml" href="https://connect.microsoft.com/rss/68/RecentlyModifiedFeedbackForConnection.xml">https://connect.microsoft.com/rss/68/RecentlyModifiedFeedbackForConnection.xml</a></p>
<p>If you haven’t been on Connect for a while and wonder what’s out there, well I’ve got a PowerShell script for you <img class="wlEmoticon wlEmoticon-openmouthedsmile" style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/wlEmoticon-openmouthedsmile.png" alt="Open-mouthed smile" /> </p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff;">Invoke-Sqlcmd</span> <span style="color: #000080;">-ServerInstance</span> <span style="color: #8a2be2;">denali.db.5026258.hostedresource.com</span> <span style="color: #000000;">`
</span><span style="color: #000080;">-Database</span> <span style="color: #8a2be2;">denali</span> <span style="color: #000080;">-Username</span> <span style="color: #8a2be2;">denaliconnect</span> <span style="color: #000080;">-Password</span> <span style="color: #8a2be2;">Wide0pen</span> <span style="color: #000080;">-Query</span> <span style="color: #8b0000;">"
SELECT ID
        , Title
        , ItemStatus
        , UpVoteCount
        , DownVoteCount
        , ItemDescription
        , Author
        , Modified
        , ValidationCount
        , WorkAroundCount
        , URL
        , OpenedDate
  FROM denali.dbo.ConnectItems"</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">out-gridview</span></pre>
<p>OK, you can totally take that login info and use <span style="text-decoration: underline;">your</span> SQL Management Studio to connect to this database too but I wanted to show you a REALLY cool use for the <span style="color: #0000ff;">Out-GridView</span> command.  When run the PowerShell script and the window pops up Just Click on + Add Criteria &gt; ItemDescription &gt; Add.</p>
<p>Like this:</p>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image3.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image_thumb1.png" border="0" alt="image" width="194" height="244" /></a></p>
<p>Then just type in a search term like “SSIS” and see what you get back…</p>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image_thumb2.png" border="0" alt="image" width="355" height="370" /></a></p>
<p>Rob has also put together a way to search the data that is <a href="http://pivot.lobsterpot.com.au/ConnectItems">much better</a> and where we hope to ultimately go with it.  Again, that’s all for another post.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/7FPJef9fRFI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/is-the-connect-feed-for-sql-server-in-your-reader/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/is-the-connect-feed-for-sql-server-in-your-reader/</feedburner:origLink></item>
		<item>
		<title>Guest Posts for Hey Scripting Guy Blog on TechNet</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/OUPG6vf8vag/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2011/01/guest-posts-for-hey-scripting-guy-blog-on-technet/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 18:08:00 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[cmdlet]]></category>
		<category><![CDATA[Guest Blogger]]></category>
		<category><![CDATA[Hey Scripting Guy]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Provider]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2011/01/guest-posts-for-hey-scripting-guy-blog-on-technet/</guid>
		<description><![CDATA[Late last year I contributed three guest blogger posts to a full week of posts about PowerShell and SQL Server. The posts were published a week before the PASS Summit. In them I tried to not only cover how useful PowerShell is for automating your every day SQL tasks but also the different approaches you have for accomplishing them: PowerShell cmdlet, WMI, SMO, SQL Provider, and .Net. It’s a huge honor to get the chance to be a guest blogger on Hey Scripting Guy! and I hope these posts were able to make some people’s (o.k. A Lot of People’s) lives easier. Given the number of people checking out PowerShell for the first time based on the comments to my MCM Videos download script I figured I’d call these out today: Use PowerShell to Obtain SQL Server Database Sizes Use PowerShell to Change SQL Server Service Accounts Use PowerShell to Script SQL Database Objects I know that the Hey Scripting Guy! blog is the #1 blog on TechNet but I’m not allowed to know any specifics beyond that. I did however catch this in yesterday’s post: “In general, the articles we published on SQL Server and on SharePoint have been really popular.” So hopefully that means we’ll get to hear some more SQL voices there in the near future. Maybe even in time for SQL Rally, who knows?]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/sql+server/"><img title="image" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image.png" border="0" alt="image" width="135" height="130" align="right" /></a>Late last year I contributed three guest blogger posts to a full week of posts about <strong><a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/sql+server/"><span style="color: #0000ff;">PowerShell and SQL Server</span></a></strong>.  The posts were published a week before the PASS Summit.  In them I tried to not only cover how useful PowerShell is for automating your every day SQL tasks but also the different approaches you have for accomplishing them: PowerShell <strong>cmdlet</strong>, <strong>WMI</strong>, <strong>SMO</strong>, <strong>SQL Provider</strong>, and <strong>.Net</strong>.</p>
<p>It’s a huge honor to get the chance to be a guest blogger on Hey Scripting Guy! and I hope these posts were able to make some people’s (o.k. <strong>A Lot of People’s</strong>) lives easier.  Given the number of people checking out PowerShell for the first time based on the comments to my <a href="http://sqlvariant.com/index.php/2010/12/powershell-script-to-download-sql-mcm-videos"><strong>MCM Videos download script</strong></a> I figured I’d call these out today:</p>
<h3><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/02/use-powershell-to-obtain-sql-server-database-sizes.aspx"><span style="color: #1111b5;"><span style="font-weight: bold;">Use PowerShell to Obtain SQL Server Database Sizes</span></span></a><span style="color: #1111b5;"><span style="font-weight: bold;"> </span></span></h3>
<h3><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/03/use-powershell-to-change-sql-server-s-service-accounts.aspx"><span style="color: #1111b5;"><span style="font-weight: bold;">Use PowerShell to Change SQL Server Service Accounts</span></span></a><span style="color: #1111b5;"><span style="font-weight: bold;"> </span></span></h3>
<h3><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/04/use-powershell-to-script-sql-database-objects.aspx"><span style="color: #1111b5;"><span style="font-weight: bold;">Use PowerShell to Script SQL Database Objects</span></span></a></h3>
<h5><span style="font-weight: normal;"><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/03/the-most-popular-hey-scripting-guy-blog-articles.aspx"><img title="image" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border-width: 0px;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/image1.png" border="0" alt="image" width="244" height="50" align="right" /></a></span></h5>
<p><span style="font-weight: normal;">I know that the Hey Scripting Guy! blog is the #1 blog on <a href="http://blogs.technet.com/"><strong>TechNet</strong></a> but I’m not allowed to know any specifics beyond that.  I did however catch this in yesterday’s post: “<em>In general, the articles we published on<strong> </strong></em></span><a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/sql+server/"><em><strong>SQL Server</strong></em></a><span style="font-weight: normal;"><em><span style="font-weight: bold;"> </span>and on </em></span><a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/windows+powershell/sharepoint/"><em><strong>SharePoint</strong></em></a><span style="font-weight: normal;"><em><strong> have been really popular</strong>.” </em>So hopefully that means we’ll get to hear some more SQL voices there in the near future.  Maybe even in time for <span style="font-weight: bold;"><a href="http://www.sqlpass.org/sqlrally/2011/"><strong>SQL Rally</strong></a></span>, who knows?  <img style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2011/01/wlEmoticon-winkingsmile.png" alt="Winking smile" class="wlEmoticon wlEmoticon-winkingsmile" /></span></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/OUPG6vf8vag" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2011/01/guest-posts-for-hey-scripting-guy-blog-on-technet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2011/01/guest-posts-for-hey-scripting-guy-blog-on-technet/</feedburner:origLink></item>
		<item>
		<title>PASS AppDev VC Presents: SSIS Tips &amp; Tricks</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/btb0o2qgQLY/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2010/12/pass-appdev-vc-presents-ssis-tips-tricks/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 15:10:00 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[AppDev]]></category>
		<category><![CDATA[Free Training]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2010/12/pass-appdev-vc-presents-ssis-tips-tricks/</guid>
		<description><![CDATA[SSIS Tips &#38; Tricks 12/28/2010 12 Noon Eastern Time (GMT-5) Josef Richberg Learn some of the quirks and capabilities of SSIS. Learn about the pitfall of &#8220;parallel path choicing&#8221;. Use the Script Component as a data source (to solve complex sourcing issues) and as a data destination (to get around the identity column conundrum). See how to use Script Tasks to build directory scanners for efficient file import techniques. We&#8217;ll also go over some the tunable properties of the Data Flow object. Josef Richberg Josef is a DBA for HarperCollins Publishers working with SQL Server and SSIS.  He has over 17 years’ experience designing, building, and tuning SQL Server.  Josef was the recipient of the &#8217;2009 Exceptional DBA&#8217; award and actively blogs at http://josef-richberg.squarespace.com. How do I view the presentation? Attendee URL:  Live Meeting link]]></description>
			<content:encoded><![CDATA[<p><a href="http://appdev.sqlpass.org/"><img style="display: inline; float: right;" src="http://www.sqlpass.org/Portals/_default/Skins/pass_skins_fixed_smallbanner/pass_logo.gif" alt="www.sqlpass.org" align="right" /></a><strong>SSIS Tips &amp; Tricks<br />
12/28/2010 12 Noon Eastern Time (GMT-5)<br />
Josef Richberg</strong></p>
<p>Learn some of the quirks and capabilities of SSIS. Learn about the pitfall of &#8220;parallel path choicing&#8221;. Use the Script Component as a data source (to solve complex sourcing issues) and as a data destination (to get around the identity column conundrum). See how to use Script Tasks to build directory scanners for efficient file import techniques. We&#8217;ll also go over some the tunable properties of the Data Flow object.</p>
<p><strong>Josef Richberg</strong><br />
Josef is a DBA for HarperCollins Publishers working with SQL Server and SSIS.  He has over 17 years’ experience designing, building, and tuning SQL Server.  Josef was the recipient of the &#8217;2009 Exceptional DBA&#8217; award and actively blogs at <a href="http://josef-richberg.squarespace.com/">http://josef-richberg.squarespace.com</a>.</p>
<p><strong>How do I view the presentation?<br />
</strong>Attendee URL:  <a href="https://www.livemeeting.com/cc/usergroups/join?id=BKKJ7Z&amp;role=attend">Live Meeting link</a></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/btb0o2qgQLY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2010/12/pass-appdev-vc-presents-ssis-tips-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2010/12/pass-appdev-vc-presents-ssis-tips-tricks/</feedburner:origLink></item>
		<item>
		<title>Quick Blog: What’s Missing From SQLPS</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/v1IrudMFh6o/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2010/12/quick-blog-whats-missing-from-sqlps/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 20:14:54 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLPS.exe]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/index.php/2010/12/quick-blog-whats-missing-from-sqlps/</guid>
		<description><![CDATA[Last week Norm Kelm ( blog &#124; twitter ) asked me on twitter ‘What cmdlets/features are missing from SQLPS.exe? Get-Snapin, etc. Where&#8217;s a doc that explains?’   To get the cmdlet half of this answer is somewhat easy in PowerShell using Compare-Object but it made me realize this is one of the many PowerShell tips that I have failed to blog about yet!  I plan to fix that next year with a deluge of blog posts but why wait until next year right? To get a very fast answer to this answer I opened up PowerShell.exe because while I normally demo in PowerShell_ISE.exe, I don’t use a profile in PowerShell.exe (more on that in a later post).  I ran this command to get the count of just the cmdlets. (get-command -CommandType Cmdlet).count Then I fired up SQLPS.exe (typically found in C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn) and ran the same command (after switching out of SQL Server and over to the C drive; no idea why that was necessary). The only problem here is that it’s not really 236 – 130 = 106 because SQLPS.exe adds 5 cmdlets that I made sure to exclude (along with everything else I normally use) from PowerShell.exe.  To get a more accurate list of the cmdlets and which one has what I decided to write a script that everyone con run on their own machine.  One of the many cool features of PowerShell is that you call call it’s executable and pass it a -command or even a –file.  I went ahead and threw together this simple command below so that you can see the differences yourself. Note: I assume you are running Windows 7 which comes with PowerShell 2.0 $SQLPS=SQLPS.exe -command "CD C:\; get-command -CommandType Cmdlet &#124; select CommandType, Name; exit"; $PSTwo=powershell.exe -command "get-command -CommandType Cmdlet &#124; select CommandType, Name; exit"; Compare-Object -ReferenceObject $SQLPS -DifferenceObject $PSTwo&#124; Export-CSV C:\temp\SQLPSCommandDifferences.csv -NoTypeInformation Now all that you have to do is open up that csv file that was just created (C:\temp\SQLPSCommandDifferences.csv) and have a look.  Note: I could have just displayed the info inside of my PowerShell window by leaving off the last line and the pipe but then I would have needed to do something to format the output so I went with the CSV file instead. For more information on this topic be sure to check out Chad Miller’s post on it.]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image11.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image_thumb11.png" border="0" alt="image" width="118" height="48" align="right" /></a>Last week Norm Kelm ( <a href="http://www.gerasus.com/">blog</a> | <a href="http://twitter.com/normankelm">twitter</a> ) asked me on <a href="http://twitter.com/#!/normankelm/statuses/18042366854176768">twitter</a> <em>‘What cmdlets/features are missing from SQLPS.exe? Get-Snapin, etc. Where&#8217;s a doc that explains?’</em>   To get the cmdlet half of this answer is somewhat easy in PowerShell using <span style="color: #0000ff;"><strong>Compare-Object</strong></span> but it made me realize this is one of the many PowerShell tips that I have failed to blog about yet!  I plan to fix that next year with a deluge of blog posts but why wait until next year right?</p>
<p>To get a very fast answer to this answer I opened up <span style="color: #0000ff;">PowerShell.exe</span> because while I normally demo in PowerShell_ISE.exe, I don’t use a <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2009/11/23/hey-scripting-guy-how-can-i-use-profiles-with-windows-powershell.aspx">profile</a> in PowerShell.exe (more on that in a later post).  I ran this command to get the count of just the cmdlets.</p>
<pre class="PowerShellColorizedScript"><span style="color: #000000;">(</span><span style="color: #0000ff;">get-command</span> <span style="color: #000080;">-CommandType</span> <span style="color: #8a2be2;">Cmdlet</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">count</span></pre>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image21.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image_thumb21.png" border="0" alt="image" width="414" height="72" /></a></p>
<p>Then I fired up <span style="color: #0000ff;">SQLPS.exe</span> (typically found in <span style="color: #000080;">C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn</span>) and ran the same command (after switching out of SQL Server and over to the C drive; no idea why that was necessary).</p>
<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image31.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image_thumb31.png" border="0" alt="image" width="457" height="129" /></a></p>
<p>The only problem here is that it’s not really 236 – 130 = 106 because SQLPS.exe adds 5 cmdlets that I made sure to exclude (along with everything else I normally use) from PowerShell.exe. </p>
<p>To get a more accurate list of the cmdlets and which one has what I decided to write a script that everyone con run on their own machine.  One of the many cool features of PowerShell is that you call call it’s executable and pass it a <span style="color: #000040;">-command</span> or even a <span style="color: #000040;">–file</span>.  I went ahead and threw together this simple command below so that you can see the differences yourself.</p>
<p><span style="text-decoration: underline;">Note: I assume you are running Windows 7 which comes with PowerShell 2.0</span></p>
<pre class="PowerShellColorizedScript" style="width: 539px; height: 138px;"><span style="color: #ff4500;">$SQLPS</span><span style="color: #a9a9a9;">=</span><span style="color: #0000ff;">SQLPS.exe</span> <span style="color: #000080;">-command</span> <span style="color: #8b0000;">"CD C:\; get-command -CommandType Cmdlet | select CommandType, Name; exit"</span><span style="color: #000000;">;</span>
<span style="color: #ff4500;">$PSTwo</span><span style="color: #a9a9a9;">=</span><span style="color: #0000ff;">powershell.exe</span> <span style="color: #000080;">-command</span> <span style="color: #8b0000;">"get-command -CommandType Cmdlet | select CommandType, Name; exit"</span><span style="color: #000000;">;</span>

<span style="color: #0000ff;">Compare-Object</span> <span style="color: #000080;">-ReferenceObject</span> <span style="color: #ff4500;">$SQLPS</span> <span style="color: #000080;">-DifferenceObject</span> <span style="color: #ff4500;">$PSTwo</span><span style="color: #a9a9a9;">|</span>
<span style="color: #0000ff;">Export-CSV</span> <span style="color: #8a2be2;">C:\temp\SQLPSCommandDifferences.csv</span> <span style="color: #000080;">-NoTypeInformation</span></pre>
<p>Now all that you have to do is open up that csv file that was just created (<span style="color: #000080;">C:\temp\SQLPSCommandDifferences.csv</span>) and have a look. </p>
<p>Note: I could have just displayed the info inside of my PowerShell window by leaving off the last line and the pipe but then I would have needed to do something to format the output so I went with the CSV file instead.</p>
<p>For more information on this topic be sure to check out <a href="http://sev17.com/2010/05/the-truth-about-sqlps-and-powershell-v2/">Chad Miller’s post on it</a>.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/v1IrudMFh6o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2010/12/quick-blog-whats-missing-from-sqlps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2010/12/quick-blog-whats-missing-from-sqlps/</feedburner:origLink></item>
		<item>
		<title>PASS Summit 2010 Feedback Results Are In</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/zKMxclTAP4I/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2010/12/pass-summit-2010-feedback-results-are-in/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 15:08:18 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[Brother Jason]]></category>
		<category><![CDATA[PASS Summit 2010]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Session feedback]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=1765</guid>
		<description><![CDATA[I got my PASS Summit 2010 Feedback earlier this week and am blown away with the results! Actually, I’m humbled, very humbled. Before I bore you with the scores or anything: today is my brother Jason’s Birthday ( blog &#124; twitter &#124; flickr ) so I thought I’d share with you some pictures he took while he was out there with us at the PASS Summit. This one is taken from the Columbia Tower (the REALLY tall black building, well I guess it’s not actually that tall, I mean it’s not as tall as Bank of America Plaza in Atlanta but anyways…). The Columbia tower is a much better deal than the Space Needle, it only costs $5 to go up and it’s MUCH taller. Onto the boring part: I put a lot of work into that session and even on the day of the event I was still second-guessing what scripts to put in and which to leave-out. Thankfully fellow [PowerShell] speaker Trevor Barkhouse ( blog &#124; twitter ) sat through my entire presentation that morning and helped me carefully tweak the sequence of scripts. I had the 4th most well attended session of the 186 sessions at the PASS Summit on the official scoring list I was sent! My scores were nothing short of amazing considering I had never spoken on a stage this large before. Even if you leave the whole first-time-at-Summit-speaker thing out I still scored just above the midpoint for all speakers at the Summit. Not half bad for a n00b &#60;—Literally! I am not a professional speaker. In fact I have been speaking for less than a year still. I had a time budget in preparation and I had to make trade offs. I decided to focus vastly more time on demos and script flow than slides or things like inserting jokes in the session. I’ll definitely work to improve the things that people comment on and I’ll share those in a later post (short on time today). The Scores: How would you rate the… Score amount of time allocated to cover the topic/session? 4.17 Speaker&#8217;s presentation skills? 4.33 quality of the presentation materials? 4.41 usefulness of the information presented in your day-to-day environment? 4.46 accuracy of the session title, description and experience level to the actual session? 4.5 Speaker&#8217;s knowledge of the subject? 4.62 Time allotted: Based on the comments from people who came up and talked to me afterwards at the Summit, they would have loved for me to have kept going for another 20 minutes. I don’t think Adam Machanic ( blog &#124; twitter ) would have appreciated that much but I sure had the material for it! Presentation skills:I will definitely work on upping my presentation skills but this is the toughest competition I’ve ever been up against so not half bad! Quality of the materials: This may have been lowered because of the many A/V related comments I received. Or maybe refining my presentation skills will help this too. Usefulness in your day-to-day environment: is the entire reason I put the presentation together in the first place. My goal for this particular score is not a number but a note from the organizers mentioning the shocking number of people who scratched out the choices and wrote in a number above the range. I will not let people down the next time Accuracy of title: I have some ideas on how to tweak the abstract a little but I’m happy with this score. Speaker’s knowledge: I’m happy with this score. I’m sure Adam (who was speaking right after me) got nothing but 5s on this score. Considering the company, my score was stellar. I will not spend any time thinking about let alone trying to improve this score. I’ll post the comments I received in a separate post. Gotta run. Oh btw… that table up there. Generated if off of an Excel spreadsheet using a single line of PowerShell code! (I’ll blog that soon, promise.)]]></description>
			<content:encoded><![CDATA[<p><img style="display: inline; float: right;" src="http://2.bp.blogspot.com/_ksXWJ2pdD2Y/TOWvDzmgAAI/AAAAAAAAAK0/GMLLN6eKk3w/s1600/Seattles+Columbia+Center+Obseration+Deck+copy.jpg" alt="" width="377" height="387" align="right" />I got my PASS Summit 2010 Feedback earlier this week and am blown away with the results!  Actually, I’m humbled, <strong>very humbled</strong>.  Before I bore you with the scores or anything: today is my brother Jason’s Birthday ( <a href="http://jasonscottmckinney.blogspot.com/">blog</a> | <a href="http://www.twitter.com/pangeist">twitter</a> | <a href="http://www.flickr.com/photos/pangeist">flickr</a> ) so I thought I’d share with you some pictures he took while he was out there with us at the PASS Summit.  This one is taken from the <a href="http://en.wikipedia.org/wiki/Columbia_Center">Columbia Tower</a> (the REALLY tall black building, well I guess it’s not actually that tall, I mean it’s not as tall as <a href="http://en.wikipedia.org/wiki/Bank_of_America_Plaza_(Atlanta)">Bank of America Plaza in Atlanta</a> <img style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/wlEmoticon-winkingsmile11.png" alt="Winking smile" class="wlEmoticon wlEmoticon-winkingsmile" /> but anyways…).  The Columbia tower is a much better deal than the Space Needle, it only costs $5 to go up and it’s MUCH taller.</p>
<p><strong><img style="display: inline; float: left;" src="http://2.bp.blogspot.com/_ksXWJ2pdD2Y/TNkGbD6HMhI/AAAAAAAAAKo/ErVXyv1a5Pw/s1600/026+copy.jpg" alt="" width="352" height="199" align="left" />Onto the boring part:<br />
</strong>I put a lot of work into that session and even on the day of the event I was still second-guessing what scripts to put in and which to leave-out.  Thankfully fellow [PowerShell] speaker Trevor Barkhouse ( <a href="http://sqlserversleuth.com/">blog</a> | <a href="http://twitter.com/SQLServerSleuth">twitter</a> ) sat through my entire presentation that morning and helped me carefully tweak the sequence of scripts.  I had the 4th most well attended session of the 186 sessions at the <a href="http://www.sqlpass.org/summit/na2010/">PASS Summit</a> on the official scoring list I was sent!  My scores were nothing short of amazing considering I had never spoken on a stage this large before.  Even if you leave the whole first-time-at-Summit-speaker thing out I still scored just above the midpoint for all speakers at the Summit.  Not half bad for a n00b &lt;—Literally!</p>
<p>I am not a professional speaker.  In fact I have been speaking for less than a year still.  I had a time budget in preparation and I had to make trade offs.  I decided to focus vastly more time on demos and script flow than slides or things like inserting jokes in the session.  I’ll definitely work to improve the things that people comment on and I’ll share those in a later post (short on time today).</p>
<p><strong>The Scores:</strong></p>
<table>
<colgroup span="1">
<col span="1"></col>
<col span="1"></col>
</colgroup>
<tbody>
<tr>
<th>How would you rate the…</th>
<th>Score</th>
</tr>
<tr>
<td>amount of time allocated to cover the topic/session?</td>
<td>4.17</td>
</tr>
<tr>
<td>Speaker&#8217;s presentation skills?</td>
<td>4.33</td>
</tr>
<tr>
<td>quality of the presentation materials?</td>
<td>4.41</td>
</tr>
<tr>
<td>usefulness of the information presented in your day-to-day environment?</td>
<td>4.46</td>
</tr>
<tr>
<td>accuracy of the session title, description and experience level to the actual session?</td>
<td>4.5</td>
</tr>
<tr>
<td>Speaker&#8217;s knowledge of the subject?</td>
<td>4.62</td>
</tr>
</tbody>
</table>
<p>Time allotted:  Based on the comments from people who came up and talked to me afterwards at the Summit, they would have loved for me to have kept going for another 20 minutes.  I don’t think Adam Machanic ( <a href="http://sqlblog.com/blogs/adam_machanic/default.aspx">blog</a> | <a href="http://twitter.com/AdamMachanic">twitter</a> ) would have appreciated that much but I sure had the material for it!  <img style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/wlEmoticon-smile21.png" alt="Smile" class="wlEmoticon wlEmoticon-smile" /></p>
<p>Presentation skills:I will definitely work on upping my presentation skills but this is the toughest competition I’ve ever been up against so not half bad!</p>
<p>Quality of the materials:  This may have been lowered because of the many A/V related comments I received.  Or maybe refining my presentation skills will help this too.</p>
<p>Usefulness in your day-to-day environment: is the <strong>entire reason I put the presentation together in the first place</strong>.  My goal for this particular score is not a number but a note from the organizers mentioning the shocking number of people who scratched out the choices and wrote in a number above the range.  I will not let people down the next time <img style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/wlEmoticon-winkingsmile11.png" alt="Winking smile" class="wlEmoticon wlEmoticon-winkingsmile" /></p>
<p>Accuracy of title: I have some ideas on how to tweak the abstract a little but I’m happy with this score.</p>
<p>Speaker’s knowledge:  I’m happy with this score.  I’m sure Adam (who was speaking right after me) got nothing but 5s on this score.  Considering the company, my score was <strong>stellar</strong>.  I will not spend any time thinking about let alone trying to improve this score.</p>
<p>I’ll post the comments I received in a separate post.  Gotta run.</p>
<p>Oh btw…  that table up there.  Generated if off of an Excel spreadsheet using a <strong>single line</strong> of PowerShell code!  (I’ll blog that soon, promise.)</p>
<p><img src="http://4.bp.blogspot.com/_ksXWJ2pdD2Y/TOWqlYfvQnI/AAAAAAAAAKw/69eqzfCOFew/s1600/022+copy.jpg" alt="" /></p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/zKMxclTAP4I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2010/12/pass-summit-2010-feedback-results-are-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2010/12/pass-summit-2010-feedback-results-are-in/</feedburner:origLink></item>
		<item>
		<title>PowerShell Script to Download SQL MCM Videos</title>
		<link>http://feedproxy.google.com/~r/Sqlvariations/~3/qe1EZoKUnBQ/</link>
		<comments>http://sqlvariant.com/wordpress/index.php/2010/12/powershell-script-to-download-sql-mcm-videos/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 14:17:55 +0000</pubDate>
		<dc:creator>Aaron Nelson</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[MCM]]></category>
		<category><![CDATA[RegEx]]></category>
		<category><![CDATA[RSS feed]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[Video Download]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://sqlvariant.com/wordpress/?p=1747</guid>
		<description><![CDATA[Microsoft has made changes to the Microsoft Certified Master program for SQL Server to make it much more accessible to everyone.  In short if you have the required credentials (MCITP: DBA 2008, DBD 2008), the required skills, and $2,500; you too can become an MCM for SQL Server.  Microsoft has partnered with SQLskills to produce 40 hours of introductory MCM training material videos which they have made freely available to everyone.  If you’d like more training than just the videos SQLskills has some classes that you can attend. If you’re like me you’ve either already downloaded the videos or you’re not even reading this right now because you clicked the link and just started downloading the videos.    Well if you don’t want to spend the rest of your day downloading all of those videos by hand I’ve got a little PowerShell script I think you’ll enjoy. $wc = new-object net.webclient [regex]$regex ="(?&#60;url&#62;http://download.microsoft.com/download/./././[0-f]{8}-[0-f]{4}-[0-f]{4}-[0-f]{4}-[0-f]{12}/(?&#60;file&#62;[^&#62;]*?wmv))" [xml]$xml = $wc.DownloadString("http://www.microsoft.com/feeds/TechNet/en-us/How-to-videos/SQL_Server_2008_Microsoft_Certified_Master_(MCM)_Readiness_Videos.xml") $xml.rss.channel.item &#124; foreach { if ($wc.DownloadString($_.link) -match $regex) { $url = $matches.url $file = "$home\Videos\$($matches.file)" if (Test-Path $file) {Write-Host "$file is already there mate"} else { Write-Host "Downloading $file" $wc.DownloadFile($url,$file) } } } This script will check the RSS feed, connect to all of the links in it, find the first .wmv link that it comes across, then copy that file to your videos directory in your documents folder IF it’s not already there.  If you have to stop this script that’s fine, it will figure out which videos have already been downloaded and skip them*.  If you want to try downloading the .MP4 files instead, just swap out .wmv for .mp4 and you should be all set.  A warning about that though; they seem to be a little more than twice the size of the .wmv files *This script is written for Windows 7 and maybe for Windows Vista.  You&#8217;ll have to edit it yourself for Windows XP or just bug Nic Cain to post one **IMPORTANT:  I think I have fixed the HTML rendering issues for the code block but you may need to download the script here. PowerShell First Timers! First off, welcome to the best addiction that you will ever have!  Since so many people are checking out this post and firing up PowerShell for the first time, I&#8217;ve gathered together some useful links.  Here&#8217;s one from the ScriptingGuys themselves: How Do I Install PowerShell on Windows 7 and Other Questions  I have a series of posts you may want to look at to help you get up &#38; running as well as a video I did a while back for MSDN&#8217;s geekSpeak: PowerShell Week Post 0 (5/17) PowerShell Week Post 1 (5/18) PowerShell Week Post 2 (5/20) PowerShell Week Post 3 (5/20) I’ll blog more later this week about how I put together the script but I wanted to get it into people’s hands ASAP.  Special Thanks go out to Jeremiah Peschka ( blog &#124; twitter ) for not laughing too hard at my first ever attempt at a RegEx as well as Nicolas Cain ( blog &#124; twitter ) &#38; Chad Miller (Blog&#124;Twitter) for giving me pointers on how to use my new RegEx hammer inside of PowerShell.]]></description>
			<content:encoded><![CDATA[<p><a href="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/image_thumb4.png" border="0" alt="image" width="68" height="67" align="right" /></a>Microsoft has made <a href="http://www.microsoft.com/presspass/features/2010/nov10/11-09sqlservermcm.mspx?rss_fdn=Custom">changes</a> to the Microsoft Certified Master program for SQL Server to make it much more accessible to everyone.  In short if you have the required credentials (MCITP: DBA 2008, DBD 2008), the required skills, and $2,500; you too can become an MCM for SQL Server.  Microsoft has partnered with <a href="http://www.sqlskills.com/T_SQLskillsMasterImmersionEvents.asp">SQLskills</a> to produce <a href="http://technet.microsoft.com/en-us/sqlserver/ff977043.aspx">40 hours</a> of introductory MCM training material videos which they have made freely available to everyone. </p>
<p>If you’d like more training than just the videos SQLskills has some <a href="http://www.sqlskills.com/T_SQLskillsMasterImmersionEvents.asp">classes</a> that you can attend.</p>
<p><a href="http://sqlvariant.com/BlogSupport/Scripts/PowerShell/Download-MCMVideos.zip"><img style="display: inline; float: right;" src="http://powershell.sqlpass.org/Portals/74/icons/Windows_PowerShell_icon-102x102.png" alt="" width="102" height="102" align="right" /></a>If you’re like me you’ve either already downloaded the videos or you’re not even reading this right now because you clicked the link and just started downloading the videos.  <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://sqlvariant.com/wordpress/wp-content/uploads/2010/12/wlEmoticon-smile11.png" alt="Smile" />  Well if you don’t want to spend the rest of your day downloading all of those videos by hand I’ve got a little <a href="http://sqlvariant.com/BlogSupport/Scripts/PowerShell/Download-MCMVideos.zip">PowerShell script</a> I think you’ll enjoy.</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$wc</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">new-object</span> <span style="color: #8a2be2;">net.webclient</span>
<span style="color: #008080;">[regex]</span><span style="color: #ff4500;">$regex</span> <span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"(?&lt;<span style="color: #8b0000;">url&gt;</span><span style="color: #8b0000;">http://download.microsoft.com/download/./././[0-f]{8}-[0-f]{4}-[0-f]{4}-[0-f]{4}-[0-f]{12}/(?&lt;file&gt;[^&gt;]*?wmv))"</span>
<span style="color: #008080;">[xml]</span><span style="color: #ff4500;">$xml</span> <span style="color: #a9a9a9;">=</span>  <span style="color: #ff4500;">$wc</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">DownloadString</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"http://www.microsoft.com/feeds/TechNet/en-us/How-to-videos/SQL_Server_2008_Microsoft_Certified_Master_(MCM)_Readiness_Videos.xml"</span><span style="color: #000000;">)</span>
<span style="color: #ff4500;">$xml</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">rss</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">channel</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">item</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">foreach</span> <span style="color: #000000;">{</span>
    <span style="color: #00008b;">if</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$wc</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">DownloadString</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">link</span><span style="color: #000000;">)</span> <span style="color: #a9a9a9;">-match</span> <span style="color: #ff4500;">$regex</span><span style="color: #000000;">)</span>
    <span style="color: #000000;">{</span>
        <span style="color: #ff4500;">$url</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$matches</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">url</span>
        <span style="color: #ff4500;">$file</span> <span style="color: #a9a9a9;">=</span>  <span style="color: #8b0000;">"$home\Videos\$($matches.file)"</span>
        <span style="color: #00008b;">if</span> <span style="color: #000000;">(</span><span style="color: #0000ff;">Test-Path</span> <span style="color: #ff4500;">$file</span><span style="color: #000000;">)</span>
        <span style="color: #000000;">{</span><span style="color: #0000ff;">Write-Host</span> <span style="color: #8b0000;">"$file is already there mate"</span><span style="color: #000000;">}</span>
        <span style="color: #00008b;">else</span> <span style="color: #000000;">{</span>
            <span style="color: #0000ff;">Write-Host</span> <span style="color: #8b0000;">"Downloading $file"</span>
            <span style="color: #ff4500;">$wc</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">DownloadFile</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$url</span><span style="color: #a9a9a9;">,</span><span style="color: #ff4500;">$file</span><span style="color: #000000;">)</span>
        <span style="color: #000000;">}</span>
    <span style="color: #000000;">}</span>
<span style="color: #000000;">}</span></span></pre>
<p>This script will check the RSS feed, connect to all of the links in it, find the first .wmv link that it comes across, then copy that file to your videos directory in your documents folder IF it’s not already there.  If you have to stop this script that’s fine, it will figure out which videos have already been downloaded and skip them*.  If you want to try downloading the .MP4 files instead, just swap out .wmv for .mp4 and you should be all set.  A warning about that though; they seem to be a little more than twice the size of the .wmv files</p>
<p>*This script is written for Windows 7 and maybe for Windows Vista.  You&#8217;ll have to edit it yourself for Windows XP or just bug Nic Cain to post one <img src='http://sqlvariant.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
**<span style="color: #ff0000;">IMPORTANT:</span>  I think I have fixed the HTML rendering issues for the code block but you may need to <strong>download the script </strong><a href="http://sqlvariant.com/BlogSupport/Scripts/PowerShell/Download-MCMVideos.zip"><strong>here</strong></a><span style="color: #800000;"><span style="color: #000000;">.</span></span></p>
<h3><span style="color: #800000;"><span style="color: #000080;">PowerShell First Timers!</span></span></h3>
<p>First off, welcome to the best addiction that you will ever have!  Since so many people are checking out this post and firing up PowerShell for the first time, I&#8217;ve gathered together some useful links.  Here&#8217;s one from the ScriptingGuys themselves:<strong> </strong><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/07/how-do-i-install-powershell-on-windows-7-and-other-questions.aspx#Q1"><strong>How Do I Install PowerShell on Windows 7 and Other Questions</strong></a> </p>
<p>I have a series of posts you may want to look at to help you get up &amp; running as well as a video I did a while back for<strong> </strong><a href="http://channel9.msdn.com/shows/geekSpeak/geekSpeak-Recording-Powershell-for-Data-Professionals/"><strong>MSDN&#8217;s geekSpeak</strong></a>:<object style="width: 400px; height: 400px;" classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" width="400" height="400" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"><param name="autostart" value="false" /><param name="url" value="http://ecn.channel9.msdn.com/o9/ch9/7/8/5/8/4/5/geekSpeakPowershell_2MB_ch9.wmv" /><param name="align" value="right" /><embed style="width: 400px; height: 400px;" type="application/x-mplayer2" width="400" height="400" src="http://ecn.channel9.msdn.com/o9/ch9/7/8/5/8/4/5/geekSpeakPowershell_2MB_ch9.wmv" autostart="false" align="right"></embed></object><br />
<a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-0/">PowerShell Week Post 0</a> (5/17)<br />
<a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-1/">PowerShell Week Post 1</a> (5/18)<br />
<a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-2/">PowerShell Week Post 2</a> (5/20)<br />
<a href="http://sqlvariant.com/wordpress/index.php/2010/05/powershell-week-at-sql-university-post-3/">PowerShell Week Post 3</a> (5/20)</p>
<p>I’ll blog more later this week about how I put together the script but I wanted to get it into people’s hands ASAP.  Special Thanks go out to <strong>Jeremiah Peschka</strong> ( <a href="http://facility9.com/">blog</a> | <a href="http://twitter.com/peschkaj">twitter</a> ) for not laughing too hard at my first ever attempt at a RegEx as well as <strong>Nicolas Cain</strong> ( <a href="http://www.englishtosql.com/">blog</a> | <a href="http://twitter.com/anonythemouse">twitter</a> ) &amp; <strong>Chad Miller</strong> (<a href="http://sev17.com/">Blog</a>|<a href="http://www.twitter.com/cmille19">Twitter</a>) for giving me pointers on how to use my new RegEx hammer inside of PowerShell.</p>
<img src="http://feeds.feedburner.com/~r/Sqlvariations/~4/qe1EZoKUnBQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://sqlvariant.com/wordpress/index.php/2010/12/powershell-script-to-download-sql-mcm-videos/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
<enclosure url="http://ecn.channel9.msdn.com/o9/ch9/7/8/5/8/4/5/geekSpeakPowershell_2MB_ch9.wmv" length="205363119" type="video/asf" />
		<feedburner:origLink>http://sqlvariant.com/wordpress/index.php/2010/12/powershell-script-to-download-sql-mcm-videos/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic (Requested URI is rejected)

Served from: sqlvariant.com @ 2012-02-04 01:50:27 -->

