<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>youdidwhatwithtsql.com &#187; DBA</title>
	<atom:link href="http://www.youdidwhatwithtsql.com/category/dba/feed" rel="self" type="application/rss+xml" />
	<link>http://www.youdidwhatwithtsql.com</link>
	<description>making DBAs everywhere curse!</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Check Mirroring Status with Powershell</title>
		<link>http://www.youdidwhatwithtsql.com/check-mirroring-status-powershell/1436</link>
		<comments>http://www.youdidwhatwithtsql.com/check-mirroring-status-powershell/1436#comments</comments>
		<pubDate>Tue, 31 Jan 2012 12:21:23 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[mirroring]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/?p=1436</guid>
		<description><![CDATA[Here&#8217;s a simple Powershell snippet to check the mirroring status on your SQL Server instances. ?View Code POWERSHELL# Load SMO extension &#91;System.Reflection.Assembly&#93;::LoadWithPartialName&#40;&#34;Microsoft.SqlServer.Smo&#34;&#41; &#124; Out-Null; &#160; # Servers to check $sqlservers = @&#40;&#34;server1&#34;, &#34;server2&#34;, &#34;server3&#34;&#41;; foreach&#40;$server in $sqlservers&#41; &#123; $srv = New-Object &#34;Microsoft.SqlServer.Management.Smo.Server&#34; $server; # Get mirrored databases $databases = $srv.Databases &#124; Where-Object &#123;$_.IsMirroringEnabled -eq $true&#125;; Write-Host [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/check-mirroring-status-powershell/1436">Check Mirroring Status with Powershell</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a simple <a title="Windows Powershell" href="http://technet.microsoft.com/en-us/scriptcenter/dd742419" target="_blank">Powershell</a> snippet to check the <a title="SQL Server Mirroring Status" href="http://msdn.microsoft.com/en-us/library/ms365781.aspx" target="_blank">mirroring status</a> on your SQL Server instances.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1436code2'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14362"><td class="code" id="p1436code2"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Load SMO extension</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadWithPartialName</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Microsoft.SqlServer.Smo&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>;
&nbsp;
<span style="color: #008000;"># Servers to check</span>
<span style="color: #800080;">$sqlservers</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;server1&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;server2&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;server3&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$server</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$sqlservers</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$srv</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> <span style="color: #800000;">&quot;Microsoft.SqlServer.Management.Smo.Server&quot;</span> <span style="color: #800080;">$server</span>;
	<span style="color: #008000;"># Get mirrored databases</span>
	<span style="color: #800080;">$databases</span> <span style="color: pink;">=</span> <span style="color: #800080;">$srv</span>.Databases <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.IsMirroringEnabled <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#125;</span>; 
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$server</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;==================================&quot;</span>;
	<span style="color: #800080;">$databases</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Name<span style="color: pink;">,</span> MirroringStatus <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-Table</span> <span style="color: #008080; font-style: italic;">-AutoSize</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>This will output something looking like below&#8230;</p>
<pre>server1
====================================

Name                 MirroringStatus
----                 ---------------
db1         		Synchronized
db2                    	Synchronized
db3              	Synchronized
db4			Synchronized
db5    			Synchronized
server2
=====================================

Name                 MirroringStatus
----                 ---------------
db1         		Synchronized
db2                    	Synchronized
db3              	Synchronized
db4			Synchronized
db5    			Synchronized
server3
=====================================

Name                 MirroringStatus
----                 ---------------
db1         		Synchronized
db2                    	Synchronized
db3              	Synchronized
db4			Synchronized
db5    			Synchronized</pre>
<p><map name='google_ad_map_1436_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1436?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1436_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1436&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fcheck-mirroring-status-powershell%2F1436' title="Check Mirroring Status with Powershell" alt=" Check Mirroring Status with Powershell" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/check-mirroring-status-powershell/1436">Check Mirroring Status with Powershell</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/check-mirroring-status-powershell/1436" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/check-mirroring-status-powershell/1436/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get-ServerErrors Powershell Function</title>
		<link>http://www.youdidwhatwithtsql.com/getservererrors-powershell-function/1431</link>
		<comments>http://www.youdidwhatwithtsql.com/getservererrors-powershell-function/1431#comments</comments>
		<pubDate>Fri, 06 Jan 2012 16:57:26 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/?p=1431</guid>
		<description><![CDATA[Here&#8217;s a little Powershell function I&#8217;m using to check the Event Logs and SQL Server Error Logs in one easy swoop; ?View Code POWERSHELLfunction Get-ServerErrors &#123; # Server to check &#38;amp; hours back. Will only support default sql instances # Could add a third param for instance and modify script where appropriate if needed param &#40;$server, [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/getservererrors-powershell-function/1431">Get-ServerErrors Powershell Function</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little Powershell function I&#8217;m using to check the <a title="Windows Event Logs" href="http://technet.microsoft.com/en-us/library/cc722404.aspx" target="_blank">Event Logs</a> and <a title="SQL server Error Logs" href="http://sqlserverpedia.com/wiki/SQL_Server_Error_Logs" target="_blank">SQL Server Error Logs</a> in one easy swoop;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1431code5'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14315"><td class="code" id="p1431code5"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">function</span> Get<span style="color: pink;">-</span>ServerErrors
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Server to check &amp;amp; hours back. Will only support default sql instances</span>
	<span style="color: #008000;"># Could add a third param for instance and modify script where appropriate if needed</span>
	<span style="color: #0000FF;">param</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$server</span><span style="color: pink;">,</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$hours</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #000000;">&#91;</span>datetime<span style="color: #000000;">&#93;</span><span style="color: #800080;">$after</span> <span style="color: pink;">=</span> $<span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-Date</span><span style="color: #000000;">&#41;</span>.AddHours<span style="color: #000000;">&#40;</span><span style="color: pink;">-</span><span style="color: #800080;">$hours</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #008000;"># Windows Event Log (Application &amp;amp; System) Errors &amp;amp; Warnings</span>
&nbsp;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Application Event Log Errors from $server after $after&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;========================================================================&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Get-EventLog</span> <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$server</span> <span style="color: #008080; font-style: italic;">-LogName</span> <span style="color: #800000;">&quot;Application&quot;</span> <span style="color: pink;">-</span>EntryType <span style="color: #800000;">&quot;Error&quot;</span> <span style="color: pink;">-</span>After <span style="color: #800080;">$after</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-List</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Press any key to continue or ctrl + c to quit&quot;</span>;
	<span style="color: #800080;">$r</span> <span style="color: pink;">=</span> <span style="color: #800080;">$host</span>.UI.RawUI.ReadKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;NoEcho,IncludeKeyDown&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;System Event Log Errors from $server after $after&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;========================================================================&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Get-EventLog</span> <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$server</span> <span style="color: #008080; font-style: italic;">-LogName</span> <span style="color: #800000;">&quot;System&quot;</span> <span style="color: pink;">-</span>EntryType <span style="color: #800000;">&quot;Error&quot;</span> <span style="color: pink;">-</span>After <span style="color: #800080;">$after</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-List</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Press any key to continue or ctrl + c to quit&quot;</span>;
	<span style="color: #800080;">$r</span> <span style="color: pink;">=</span> <span style="color: #800080;">$host</span>.UI.RawUI.ReadKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;NoEcho,IncludeKeyDown&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Application Event Log Warnings from $server after $after&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;========================================================================&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Get-EventLog</span> <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$server</span> <span style="color: #008080; font-style: italic;">-LogName</span> <span style="color: #800000;">&quot;Application&quot;</span> <span style="color: pink;">-</span>EntryType <span style="color: #800000;">&quot;Warning&quot;</span> <span style="color: pink;">-</span>After <span style="color: #800080;">$after</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-List</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Press any key to continue or ctrl + c to quit&quot;</span>;
	<span style="color: #800080;">$r</span> <span style="color: pink;">=</span> <span style="color: #800080;">$host</span>.UI.RawUI.ReadKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;NoEcho,IncludeKeyDown&quot;</span><span style="color: #000000;">&#41;</span>;	
&nbsp;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;System Event Log Warnings from $server after $after&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;========================================================================&quot;</span>;
	<span style="color: #008080; font-weight: bold;">Get-EventLog</span> <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$server</span> <span style="color: #008080; font-style: italic;">-LogName</span> <span style="color: #800000;">&quot;System&quot;</span> <span style="color: pink;">-</span>EntryType <span style="color: #800000;">&quot;Warning&quot;</span> <span style="color: pink;">-</span>After <span style="color: #800080;">$after</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-List</span>;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Press any key to continue or ctrl + c to quit&quot;</span>;
	<span style="color: #800080;">$r</span> <span style="color: pink;">=</span> <span style="color: #800080;">$host</span>.UI.RawUI.ReadKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;NoEcho,IncludeKeyDown&quot;</span><span style="color: #000000;">&#41;</span>;	
&nbsp;
	<span style="color: #008000;"># SQL Server Error Log</span>
	<span style="color: #000000;">&#91;</span>reflection.assembly<span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadWithPartialName</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Microsoft.SqlServer.Smo&quot;</span><span style="color: #000000;">&#41;</span> ;
	<span style="color: #800080;">$sql_server</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Microsoft.SqlServer.Management.Smo.Server&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #800080;">$server</span>;
	<span style="color: #800080;">$sql_server</span>.ReadErrorLog<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Text <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;Error*&quot;</span> <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.LogDate <span style="color: #FF0000;">-ge</span> <span style="color: #800080;">$after</span><span style="color: #000000;">&#125;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Usage is as follows;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1431code6'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14316"><td class="code" id="p1431code6"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>ServerErrors <span style="color: pink;">&lt;</span>server name<span style="color: pink;">&gt;</span> <span style="color: pink;">&lt;</span>hours back to check<span style="color: pink;">&gt;</span>;</pre></td></tr></table></div>

<p><map name='google_ad_map_1431_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1431?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1431_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1431&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fgetservererrors-powershell-function%2F1431' title="Get ServerErrors Powershell Function" alt=" Get ServerErrors Powershell Function" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/getservererrors-powershell-function/1431">Get-ServerErrors Powershell Function</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/getservererrors-powershell-function/1431" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/getservererrors-powershell-function/1431/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring SSRS Subscriptions with Powershell</title>
		<link>http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392</link>
		<comments>http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392#comments</comments>
		<pubDate>Fri, 25 Nov 2011 13:17:09 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Report Subscriptions]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/?p=1392</guid>
		<description><![CDATA[We don&#8217;t use SSRS much at my workplace but its usage is slowly creeping up. I realised that none of us are keeping an eye on the few subscriptions we have set-up. So I decided to do something about that. Here&#8217;s a bit of Powershell code that uses the SSRS Web Service to pull out [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392">Monitoring SSRS Subscriptions with Powershell</a></p>
]]></description>
			<content:encoded><![CDATA[<p>We don&#8217;t use <a title="SQL Server Reporting Services" href="http://msdn.microsoft.com/en-us/library/ms159106.aspx" target="_blank">SSRS </a>much at my workplace but its usage is slowly creeping up. I realised that none of us are keeping an eye on the few subscriptions we have set-up. So I decided to do something about that.</p>
<p>Here&#8217;s a bit of <a title="Windows Powershell" href="http://technet.microsoft.com/en-us/scriptcenter/dd742419" target="_blank">Powershell</a> code that uses the <a title="SSRS Web Service" href="http://msdn.microsoft.com/en-us/library/ms152787.aspx" target="_blank">SSRS Web Service</a> to pull out a list of subscriptions from SSRS and print out some information to the screen. As always I try to bring problems to attention with a little red text so you can identify any failed subscriptions. There&#8217;s a few assumptions in the script, so be sure to read the comments, and it&#8217;s a far from complete and fully tested script. Just a little something to get me started onto something better.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1392code8'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13928"><td class="code" id="p1392code8"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># If you use multiple ssrs server just stick in another foreach loop</span>
<span style="color: #008000;"># and iterate over an array of ssrs server names.</span>
<span style="color: #800080;">$reportserver</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;sqlserver&quot;</span>;
<span style="color: #800080;">$url</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;http://$($reportserver)/reportserver/reportservice.asmx?WSDL&quot;</span>;
&nbsp;
<span style="color: #800080;">$ssrs</span> <span style="color: pink;">=</span> New<span style="color: pink;">-</span>WebServiceProxy <span style="color: pink;">-</span>uri <span style="color: #800080;">$url</span> <span style="color: pink;">-</span>UseDefaultCredential <span style="color: #008080; font-style: italic;">-Namespace</span> <span style="color: #800000;">&quot;ReportingWebService&quot;</span>;
&nbsp;
<span style="color: #008000;"># Uncomment to list all available methods &amp;amp; properties in the ssrs web service...</span>
<span style="color: #008000;">#$ssrs | Get-Member;</span>
&nbsp;
<span style="color: #008000;"># Get datasources (assumes default path to folder)</span>
<span style="color: #800080;">$datasources</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ssrs</span>.ListChildren<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;/Data Sources&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008000;"># for each datasource</span>
<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ds</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$datasources</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Get reports</span>
	<span style="color: #800080;">$reports</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ssrs</span>.ListReportsUsingDataSource<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ds</span>.Path<span style="color: #000000;">&#41;</span>;
	<span style="color: #008000;"># For each report</span>
	<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$r</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$reports</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># Get all subscriptions</span>
		<span style="color: #800080;">$subscriptions</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ssrs</span>.ListSubscriptions<span style="color: #000000;">&#40;</span><span style="color: #800080;">$r</span>.Path<span style="color: pink;">,</span> <span style="color: #800080;">$r</span>.Owner<span style="color: #000000;">&#41;</span>;
		<span style="color: #008000;"># foreach subscription</span>
		<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$s</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$subscriptions</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #008000;"># Uncomment to view more subscription methods &amp;amp; properties</span>
			<span style="color: #008000;"># $s | Get-Member;</span>
			<span style="color: #008000;"># Probably missing a few important keywords here...</span>
			<span style="color: #800080;">$colour</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Green&quot;</span>;
			<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$s</span>.Status <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;Failure&quot;</span> <span style="color: #FF0000;">-or</span> <span style="color: #800080;">$s</span>.Status <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;Error&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$colour</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Red&quot;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800080;">$colour</span> <span style="color: #800080;">$s</span>.Report <span style="color: #800080;">$s</span>.Status <span style="color: #800080;">$s</span>.LastExecuted <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-Table</span> <span style="color: #008080; font-style: italic;">-AutoSize</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>After running this script successfully you should be something like below;</p>
<p><a href="http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392/powershell_ssrs-2" rel="attachment wp-att-1399"><img class="alignnone size-full wp-image-1399" title="powershell ssrs" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/11/powershell_ssrs1.png" alt="powershell ssrs1 Monitoring SSRS Subscriptions with Powershell" width="677" height="342" /></a></p>
<p>&nbsp;</p>
<p><map name='google_ad_map_1392_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1392?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1392_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1392&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fmonitoring-ssrs-subscriptions-powershell%2F1392' title="Monitoring SSRS Subscriptions with Powershell" alt=" Monitoring SSRS Subscriptions with Powershell" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392">Monitoring SSRS Subscriptions with Powershell</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/monitoring-ssrs-subscriptions-powershell/1392/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL Storage engine benchmarking</title>
		<link>http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384</link>
		<comments>http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384#comments</comments>
		<pubDate>Mon, 07 Nov 2011 20:49:37 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[MyISAM]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384</guid>
		<description><![CDATA[Here&#8217;s a stored procedure I use to perform some simple benchmarking of inserts for MySQL. It takes three parameters; p_table_type which should be set to the storage engine you wish to benchmark i.e. &#8216;MyISAM&#8217;, &#8216;InnoDB&#8217;, p_inserts; set this to the number of inserts to perform. p_autocommit; set the autocommit variable (relevant to InnoDB only) to [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384">MySQL Storage engine benchmarking</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a stored procedure I use to perform some simple benchmarking of inserts for <a title="MySQL" href="http://dev.mysql.com" target="_blank">MySQL</a>. It takes three parameters; <strong>p_table_type</strong> which should be set to the storage engine you wish to benchmark i.e. &#8216;MyISAM&#8217;, &#8216;InnoDB&#8217;, <strong>p_inserts</strong>; set this to the number of inserts to perform. <strong>p_autocommit</strong>; set the <a title="InnoDB autocommit variable" href="http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-model.html" target="_blank">autocommit</a> variable (relevant to <a title="InnoDB Storage Engine" href="http://www.innodb.com/" target="_blank">InnoDB</a> only) to 0 or 1.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1384code13'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p138413"><td class="code" id="p1384code13"><pre class="mysql" style="font-family:monospace;">DELIMITER $$
<span style="color: #990099; font-weight: bold;">USE</span> <span style="color: #008000;">`test`</span>$$
<span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">PROCEDURE</span> <span style="color: #009900;">IF</span> <span style="color: #990099; font-weight: bold;">EXISTS</span> <span style="color: #008000;">`table<span style="color: #008080; font-weight: bold;">_</span>engine<span style="color: #008080; font-weight: bold;">_</span>test`</span>$$
        <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">DEFINER</span><span style="color: #CC0099;">=</span><span style="color: #008000;">`root`</span>@<span style="color: #008000;">`<span style="color: #008080; font-weight: bold;">%</span>`</span>
        <span style="color: #990099; font-weight: bold;">PROCEDURE</span> <span style="color: #008000;">`table<span style="color: #008080; font-weight: bold;">_</span>engine<span style="color: #008080; font-weight: bold;">_</span>test`</span><span style="color: #FF00FF;">&#40;</span><span style="color: #990099; font-weight: bold;">IN</span> p_table_type <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">20</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
                                      <span style="color: #990099; font-weight: bold;">IN</span> p_inserts    <span style="color: #999900; font-weight: bold;">INT</span><span style="color: #000033;">,</span>
                                      <span style="color: #990099; font-weight: bold;">IN</span> p_autocommit <span style="color: #999900; font-weight: bold;">TINYINT</span><span style="color: #FF00FF;">&#41;</span>
                <span style="color: #990099; font-weight: bold;">SQL SECURITY</span> <span style="color: #990099; font-weight: bold;">INVOKER</span>
        <span style="color: #990099; font-weight: bold;">BEGIN</span>
&nbsp;
                <span style="color: #990099; font-weight: bold;">DECLARE</span> sql_string <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">300</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># Set session autocommit</span>
                <span style="color: #990099; font-weight: bold;">SET</span> <span style="color: #990099; font-weight: bold;">SESSION</span> autocommit <span style="color: #CC0099;">=</span> p_autocommit<span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># TABLE TO hold session times</span>
                <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #990099; font-weight: bold;">IF <span style="color: #CC0099; font-weight: bold;">NOT</span> EXISTS</span> test_session
                             <span style="color: #FF00FF;">&#40;</span>
                                          Id         <span style="color: #999900; font-weight: bold;">INT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
                                          table_type <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">20</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>                   <span style="color: #000033;">,</span>
                                          inserts <span style="color: #999900; font-weight: bold;">INT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
                                          autocommit <span style="color: #999900; font-weight: bold;">TINYINT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span>
                                          started    <span style="color: #999900; font-weight: bold;">DATETIME</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>                          <span style="color: #000033;">,</span>
                                          finished   <span style="color: #999900; font-weight: bold;">DATETIME</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>
                             <span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #990099; font-weight: bold;">IF <span style="color: #CC0099; font-weight: bold;">NOT</span> EXISTS</span> test_session_inserts
                             <span style="color: #FF00FF;">&#40;</span>
                                          id              <span style="color: #999900; font-weight: bold;">INTEGER</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
                                          test_session_id <span style="color: #999900; font-weight: bold;">INTEGER</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>                           <span style="color: #000033;">,</span>
                                          started         <span style="color: #999900; font-weight: bold;">DATETIME</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>                          <span style="color: #000033;">,</span>
                                          finished        <span style="color: #999900; font-weight: bold;">DATETIME</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>
                             <span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># clean up ANY existing test TABLE</span>
                <span style="color: #990099; font-weight: bold;">DROP</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #009900;">IF</span> <span style="color: #990099; font-weight: bold;">EXISTS</span> test_table_type<span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #990099; font-weight: bold;">SET</span> sql_string <span style="color: #CC0099;">=</span> <span style="color: #000099;">CONCAT</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'CREATE TABLE test<span style="color: #008080; font-weight: bold;">_</span>table<span style="color: #008080; font-weight: bold;">_</span>type
					(
						id INTEGER NOT NULL PRIMARY KEY AUTO<span style="color: #008080; font-weight: bold;">_</span>INCREMENT,
						random INTEGER,
						text1 VARCHAR(10) NOT NULL,
						text2 VARCHAR(10) NOT NULL
					)ENGINE = '</span><span style="color: #000033;">,</span> p_table_type<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
                <span style="color: #808080; font-style: italic;"># PREPARE SQL AND EXECUTE</span>
                <span style="color: #990099; font-weight: bold;">SET</span> @q <span style="color: #CC0099;">=</span> sql_string<span style="color: #000033;">;</span>
                PREPARE stmt <span style="color: #990099; font-weight: bold;">FROM</span> @q<span style="color: #000033;">;</span>
                EXECUTE stmt<span style="color: #000033;">;</span>
                DEALLOCATE PREPARE stmt<span style="color: #000033;">;</span>
                <span style="color: #808080; font-style: italic;"># START the test session</span>
                <span style="color: #990099; font-weight: bold;">INSERT</span>
                <span style="color: #990099; font-weight: bold;">INTO</span>   test_session
                       <span style="color: #FF00FF;">&#40;</span>
                              table_type<span style="color: #000033;">,</span>
                              inserts<span style="color: #000033;">,</span>
                              autocommit<span style="color: #000033;">,</span>
                              started
                       <span style="color: #FF00FF;">&#41;</span>
                       <span style="color: #990099; font-weight: bold;">VALUES</span>
                       <span style="color: #FF00FF;">&#40;</span>
                              p_table_type<span style="color: #000033;">,</span>
                              p_inserts<span style="color: #000033;">,</span>
                              p_autocommit<span style="color: #000033;">,</span>
                              <span style="color: #000099;">NOW</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span>
                       <span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #990099; font-weight: bold;">SET</span> @id               <span style="color: #CC0099;">=</span> <span style="color: #000099;">LAST_INSERT_ID</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
                <span style="color: #990099; font-weight: bold;">SET</span> @i                <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span><span style="color: #000033;">;</span>
                while_loop: WHILE <span style="color: #FF00FF;">&#40;</span>@i <span style="color: #CC0099;">&lt;</span> p_inserts<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">DO</span>
                <span style="color: #808080; font-style: italic;"># Generate VALUES for insert</span>
                <span style="color: #990099; font-weight: bold;">SET</span> @random  <span style="color: #CC0099;">=</span> <span style="color: #000099;">RAND</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
                <span style="color: #990099; font-weight: bold;">SET</span> @text1   <span style="color: #CC0099;">=</span> <span style="color: #000099;">SUBSTRING</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">MD5</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">RAND</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #CC0099;">-</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
                <span style="color: #990099; font-weight: bold;">SET</span> @text2   <span style="color: #CC0099;">=</span> <span style="color: #000099;">SUBSTRING</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">MD5</span><span style="color: #FF00FF;">&#40;</span><span style="color: #000099;">RAND</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span> <span style="color: #CC0099;">-</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
                <span style="color: #990099; font-weight: bold;">SET</span> @started <span style="color: #CC0099;">=</span> <span style="color: #000099;">NOW</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
                <span style="color: #808080; font-style: italic;"># INSERT the test row</span>
                <span style="color: #990099; font-weight: bold;">INSERT</span>
                <span style="color: #990099; font-weight: bold;">INTO</span>   test_table_type
                       <span style="color: #FF00FF;">&#40;</span>
                              random<span style="color: #000033;">,</span>
                              text1 <span style="color: #000033;">,</span>
                              text2
                       <span style="color: #FF00FF;">&#41;</span>
                       <span style="color: #990099; font-weight: bold;">VALUES</span>
                       <span style="color: #FF00FF;">&#40;</span>
                              @random<span style="color: #000033;">,</span>
                              @text1 <span style="color: #000033;">,</span>
                              @text2
                       <span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># record INSERT times</span>
                        <span style="color: #990099; font-weight: bold;">INSERT</span>
                        <span style="color: #990099; font-weight: bold;">INTO</span>   test_session_inserts
                               <span style="color: #FF00FF;">&#40;</span>
                                      test_session_id<span style="color: #000033;">,</span>
                                      started        <span style="color: #000033;">,</span>
                                      finished
                               <span style="color: #FF00FF;">&#41;</span>
                               <span style="color: #990099; font-weight: bold;">VALUES</span>
                               <span style="color: #FF00FF;">&#40;</span>
                                      @id     <span style="color: #000033;">,</span>
                                      @started<span style="color: #000033;">,</span>
                                      <span style="color: #000099;">NOW</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span>
                               <span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
&nbsp;
                        <span style="color: #808080; font-style: italic;"># increment counter</span>
                        <span style="color: #990099; font-weight: bold;">SET</span> @i <span style="color: #CC0099;">=</span> @i <span style="color: #CC0099;">+</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
                <span style="color: #009900;">END</span> WHILE while_loop<span style="color: #000033;">;</span>
                <span style="color: #808080; font-style: italic;"># Finish the session</span>
                <span style="color: #990099; font-weight: bold;">UPDATE</span> test_session
                <span style="color: #990099; font-weight: bold;">SET</span>    finished <span style="color: #CC0099;">=</span> <span style="color: #000099;">NOW</span><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span>
                <span style="color: #990099; font-weight: bold;">WHERE</span>  id       <span style="color: #CC0099;">=</span> @id<span style="color: #000033;">;</span>
&nbsp;
<span style="color: #009900;">END</span>$$
DELIMITER <span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>Run your tests like so&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1384code14'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p138414"><td class="code" id="p1384code14"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CALL</span> table_engine_test<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'MyISAM'</span><span style="color: #000033;">,</span> <span style="color: #008080;">10000</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">CALL</span> table_engine_test<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'InnoDB'</span><span style="color: #000033;">,</span> <span style="color: #008080;">10000</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">CALL</span> table_engine_test<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'InnoDB'</span><span style="color: #000033;">,</span> <span style="color: #008080;">10000</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">CALL</span> table_engine_test<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'MyISAM'</span><span style="color: #000033;">,</span> <span style="color: #008080;">100000</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">CALL</span> table_engine_test<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'InnoDB'</span><span style="color: #000033;">,</span> <span style="color: #008080;">100000</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">CALL</span> table_engine_test<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'InnoDB'</span><span style="color: #000033;">,</span> <span style="color: #008080;">100000</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>The <strong>test_session</strong> contains some summary information about each of the tests;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1384code15'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p138415"><td class="code" id="p1384code15"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span>
<span style="color: #990099; font-weight: bold;">FROM</span> test_session<span style="color: #000033;">;</span></pre></td></tr></table></div>

<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/11/mysql_table_engine_test.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="mysql_table_engine_test" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/11/mysql_table_engine_test_thumb.png" alt="mysql table engine test thumb MySQL Storage engine benchmarking" width="644" height="166" border="0" /></a></p>
<p>Calculate the time taken for each test with the following query;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1384code16'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p138416"><td class="code" id="p1384code16"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span><span style="color: #000033;">,</span> TIMEDIFF<span style="color: #FF00FF;">&#40;</span>finished<span style="color: #000033;">,</span> started<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> seconds
<span style="color: #990099; font-weight: bold;">FROM</span> test_session<span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>Happy Benchmarking!</p>
<p><map name='google_ad_map_1384_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1384?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1384_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1384&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fmysql-storage-engine-benchmarking%2F1384' title="MySQL Storage engine benchmarking" alt=" MySQL Storage engine benchmarking" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384">MySQL Storage engine benchmarking</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/mysql-storage-engine-benchmarking/1384/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing a Failover Cluster with Powershell</title>
		<link>http://www.youdidwhatwithtsql.com/testing-failover-cluster-powershell/1377</link>
		<comments>http://www.youdidwhatwithtsql.com/testing-failover-cluster-powershell/1377#comments</comments>
		<pubDate>Thu, 03 Nov 2011 11:26:22 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[failover cluster]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/?p=1377</guid>
		<description><![CDATA[Just a quick Powershell snippet that I&#8217;m going to use to run validation tests on one of my staging Failover Clusters during OOH. The script below will take some services offline, run the validation tests, before bringing the appropriate cluster groups back online. The report will be saved using the date as the name. To [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/testing-failover-cluster-powershell/1377">Testing a Failover Cluster with Powershell</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Just a quick <a title="Windows Powershell" href="http://en.wikipedia.org/wiki/Windows_PowerShell" target="_blank">Powershell</a> snippet that I&#8217;m going to use to run validation tests on one of my staging Failover Clusters during OOH.</p>
<p>The script below will take some services offline, run the validation tests, before bringing the appropriate cluster groups back online. The report will be saved using the date as the name. To use this you will need to set <strong>$cluster</strong> appropriately and perhaps customize the cluster groups that are brought offline &amp; online.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1377code18'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137718"><td class="code" id="p1377code18"><pre class="powershell" style="font-family:monospace;">Import<span style="color: pink;">-</span>Module FailoverClusters;
&nbsp;
<span style="color: #008000;"># Set cluster name</span>
<span style="color: #800080;">$cluster</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Cluster&quot;</span>;
&nbsp;
<span style="color: #008000;"># Date stamp used for report name</span>
<span style="color: #800080;">$date</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span> <span style="color: #008080; font-style: italic;">-Format</span> <span style="color: #800000;">&quot;yyyyMMdd&quot;</span>;
&nbsp;
<span style="color: #008000;"># Take cluster services offline. You may need to customise this</span>
<span style="color: #008000;"># according to your specific needs</span>
Stop<span style="color: pink;">-</span>ClusterGroup <span style="color: pink;">-</span>Cluster <span style="color: #800080;">$cluster</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;ClusterDtc&quot;</span>;
Stop<span style="color: pink;">-</span>ClusterGroup <span style="color: pink;">-</span>Cluster <span style="color: #800080;">$cluster</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;SQL Server (MSSQLSERVER)&quot;</span>;
&nbsp;
<span style="color: #008000;"># Test Cluster</span>
Test<span style="color: pink;">-</span>Cluster <span style="color: pink;">-</span>Cluster <span style="color: #800080;">$cluster</span> <span style="color: pink;">-</span>ReportName <span style="color: #800000;">&quot;$date&quot;</span>;
&nbsp;
<span style="color: #008000;"># Bring services back online</span>
Start<span style="color: pink;">-</span>ClusterGroup <span style="color: pink;">-</span>Cluster <span style="color: #800080;">$cluster</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;ClusterDtc&quot;</span>;
Start<span style="color: pink;">-</span>ClusterGroup <span style="color: pink;">-</span>Cluster <span style="color: #800080;">$cluster</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;SQL Server (MSSQLSERVER)&quot;</span>;</pre></td></tr></table></div>

<p>The output will look something like below&#8230;</p>
<pre>Name                       OwnerNode                                      State
----                       ---------                                      -----
ClusterDtc            	   Node1                                 	  Offline
SQL Server (MSSQLSERVER)   Node1                                 	  Offline
WARNING: Cluster Configuration - Validate Resource Status: The test reported
some warnings..
WARNING: Network - Validate IP Configuration: The test reported some warnings..
WARNING:
Test Result:
ClusterConditionallyApproved
Testing has completed successfully. The configuration appears to be suitable
for clustering.  However, you should review the report because it may contain
warnings which you should address to attain the highest availability.
Test report file path: C:\Users\ClusterAdmin\AppData\Local\Temp\20111103.mht
20111103.mht
ClusterDtc            	   Node1                                 	 Online
SQL Server (MSSQLSERVER)   Node1                                 	 Online</pre>
<p><map name='google_ad_map_1377_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1377?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1377_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1377&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Ftesting-failover-cluster-powershell%2F1377' title="Testing a Failover Cluster with Powershell" alt=" Testing a Failover Cluster with Powershell" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/testing-failover-cluster-powershell/1377">Testing a Failover Cluster with Powershell</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/testing-failover-cluster-powershell/1377" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/testing-failover-cluster-powershell/1377/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking Disk alignment with Powershell</title>
		<link>http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362</link>
		<comments>http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362#comments</comments>
		<pubDate>Wed, 05 Oct 2011 19:36:04 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[disk alignment]]></category>
		<category><![CDATA[DISKPART]]></category>
		<category><![CDATA[StartingOffset]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362</guid>
		<description><![CDATA[Disk alignment has been well discussed on the web and the methods to check this always seem to use wmic or DISKPART. I&#8217;ve always loathed wmi so here&#8217;s a few lines of Powershell that achieves the same thing; ?View Code POWERSHELL$sqlserver = &#34;sqlinstance&#34;; # Get disk partitions $partitions = Get-WmiObject -ComputerName $sqlserver -Class Win32_DiskPartition; $partitions [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362">Checking Disk alignment with Powershell</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://itknowledgeexchange.techtarget.com/sql-server/how-much-performance-are-you-loosing-by-not-aligning-your-drives/">Disk alignment</a> has been well discussed on the web and the methods to check this always seem to use <a title="wmic and DISKPART for disgn alignment" href="http://sqlskills.com/BLOGS/PAUL/post/Using-diskpart-to-check-disk-partition-alignment.aspx">wmic or DISKPART</a>. I&#8217;ve always loathed wmi so here&#8217;s a few lines of Powershell that achieves the same thing;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1362code20'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p136220"><td class="code" id="p1362code20"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$sqlserver</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;sqlinstance&quot;</span>;
<span style="color: #008000;"># Get disk partitions</span>
<span style="color: #800080;">$partitions</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$sqlserver</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_DiskPartition;
<span style="color: #800080;">$partitions</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> DeviceId<span style="color: pink;">,</span> Name<span style="color: pink;">,</span> Description<span style="color: pink;">,</span> BootPartition<span style="color: pink;">,</span> PrimaryPartition<span style="color: pink;">,</span> Index<span style="color: pink;">,</span> Size<span style="color: pink;">,</span> BlockSize<span style="color: pink;">,</span> StartingOffset <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-Table</span> <span style="color: #008080; font-style: italic;">-AutoSize</span>;</pre></td></tr></table></div>

<p>This will display something looking like below;</p>
<pre>DeviceId              Name                  Description             BootPartition PrimaryPartition Index          Size BlockSize StartingOffset
--------              ----                  -----------             ------------- ---------------- -----          ---- --------- --------------
Disk #2, Partition #0 Disk #2, Partition #0 Installable File System         False             True     0 1099523162112       512        1048576
Disk #3, Partition #0 Disk #3, Partition #0 Installable File System         False             True     0  536878252032       512        1048576
Disk #4, Partition #0 Disk #4, Partition #0 Installable File System         False             True     0    1082130432       512          65536
Disk #5, Partition #0 Disk #5, Partition #0 Installable File System         False             True     0    1082130432       512          65536
Disk #1, Partition #0 Disk #1, Partition #0 Installable File System         False             True     0  107376279552       512        1048576
Disk #0, Partition #0 Disk #0, Partition #0 Installable File System          True             True     0     104857600       512        1048576
Disk #0, Partition #1 Disk #0, Partition #1 Installable File System         False             True     1   81684070400       512      105906176
Disk #0, Partition #2 Disk #0, Partition #2 Installable File System         False             True     2  104857600000       512    81789976576
Disk #0, Partition #3 Disk #0, Partition #3 Installable File System         False             True     3  104857600000       512   186647576576</pre>
<p>A <a href="http://msdn.microsoft.com/en-us/library/dd758814(v=sql.100).aspx">64K cluster size</a> is good for SQL Server. But what about the offset? The simple calculation below can be used to check this&#8230;</p>
<p><strong>StartingOffset / BlockSize / 128 </strong>(a 64K cluster has 128 sectors assuming a 512 block size).</p>
<p>If this calculation spits out a number with any decimal places then you have some disk aligning to do.</p>
<p><strong><font color="#666666"></font></strong></p>
<p><map name='google_ad_map_1362_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1362?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1362_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1362&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fchecking-disk-alignment-with-powershell%2F1362' title="Checking Disk alignment with Powershell" alt=" Checking Disk alignment with Powershell" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362">Checking Disk alignment with Powershell</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/checking-disk-alignment-with-powershell/1362/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Audit VLFs on your SQL Server</title>
		<link>http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358</link>
		<comments>http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358#comments</comments>
		<pubDate>Tue, 04 Oct 2011 20:47:55 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Virtual Log Files]]></category>
		<category><![CDATA[VLF]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358</guid>
		<description><![CDATA[I&#8217;ve been reading a bit about VLFs (Virtual Log Files) this week. I&#8217;ve found quite a few interesting links, especially this one, informing us that there&#8217;s such a thing as too few or too many VLFs. We can view details about VLFs using the DBCC LOGINFO TSQL command. This only works against the current database [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358">Audit VLFs on your SQL Server</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been <a href="http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx">reading a bit about VLFs</a> (Virtual Log Files) this week. I&#8217;ve found quite a few interesting links, especially this one, informing us that there&#8217;s such a thing as <a href="http://sqlskills.com/BLOGS/KIMBERLY/post/Transaction-Log-VLFs-too-many-or-too-few.aspx">too few or too many VLFs.</a> </p>
<p>We can view details about VLFs using the DBCC LOGINFO TSQL command. This only works against the current database context but I decided to make this process less tedious, and human-readable, so I knocked up a quick script;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1358code23'); return false;">View Code</a> TSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p135823"><td class="code" id="p1358code23"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">-- Create a temp table to hold log info</span>
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> #tmp_log_info
<span style="color: #808080;">&#40;</span>
      FileId <span style="color: #0000FF;">INTEGER</span>,
      FileSize <span style="color: #0000FF;">BIGINT</span>,
      StartOffSet <span style="color: #0000FF;">BIGINT</span>,
      <span style="color: #808080;">&#91;</span>Status<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">INTEGER</span>,
      FSeqNo <span style="color: #0000FF;">INTEGER</span>,
      Parity <span style="color: #0000FF;">SMALLINT</span>,
      CreateLSN <span style="color: #0000FF;">NUMERIC</span><span style="color: #808080;">&#40;</span><span style="color: #000;">38</span>,<span style="color: #000;">0</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>;
&nbsp;
<span style="color: #008080;">-- Same as above but with database name</span>
<span style="color: #008080;">-- Can insert in one statement</span>
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">TABLE</span> #log_info
<span style="color: #808080;">&#40;</span>
      FileId <span style="color: #0000FF;">INTEGER</span>,
      FileSize <span style="color: #0000FF;">BIGINT</span>,
      StartOffSet <span style="color: #0000FF;">BIGINT</span>,
      <span style="color: #808080;">&#91;</span>Status<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">INTEGER</span>,
      FSeqNo <span style="color: #0000FF;">INTEGER</span>,
      Parity <span style="color: #0000FF;">SMALLINT</span>,
      CreateLSN <span style="color: #0000FF;">NUMERIC</span><span style="color: #808080;">&#40;</span><span style="color: #000;">38</span>,<span style="color: #000;">0</span><span style="color: #808080;">&#41;</span>,
      <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">Database</span><span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">128</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>;
&nbsp;
<span style="color: #0000FF;">EXEC</span> sp_MsForEachDb <span style="color: #FF0000;">'INSERT INTO #tmp_log_info EXEC('</span><span style="color: #FF0000;">'DBCC LOGINFO(?)'</span><span style="color: #FF0000;">');
                              INSERT INTO #log_info
                               SELECT *, '</span><span style="color: #FF0000;">'?'</span><span style="color: #FF0000;">'
                              FROM #tmp_log_info;
                              TRUNCATE TABLE #tmp_log_info;'</span>;
&nbsp;
<span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">Database</span><span style="color: #808080;">&#93;</span>,
            <span style="color: #FF00FF;">COUNT</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> Vlf_count,
            <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MAX</span><span style="color: #808080;">&#40;</span>FileSize<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">FLOAT</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">/</span> <span style="color: #000;">1048576</span>  <span style="color: #0000FF;">AS</span> biggest_vlf_MB,
            <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">MIN</span><span style="color: #808080;">&#40;</span>FileSize<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">FLOAT</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">/</span> <span style="color: #000;">1048576</span> <span style="color: #0000FF;">AS</span> smallest_vlf_MB
<span style="color: #0000FF;">FROM</span> #log_info
<span style="color: #0000FF;">GROUP</span> <span style="color: #0000FF;">BY</span> <span style="color: #808080;">&#91;</span><span style="color: #0000FF;">Database</span><span style="color: #808080;">&#93;</span>
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> <span style="color: #FF00FF;">COUNT</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">DESC</span>;
&nbsp;
&nbsp;
<span style="color: #008080;">-- Clean up</span>
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TABLE</span> #tmp_log_info;
<span style="color: #0000FF;">DROP</span> <span style="color: #0000FF;">TABLE</span> #log_info;</pre></td></tr></table></div>

<p>This will display a summary report for all databases on the instance of SQL Server.</p>
<p><strong>Database &#8211; </strong>The database the log file belongs to.</p>
<p><strong>Vlf_count &#8211; </strong>The total number of VLFs.</p>
<p><strong>biggest_vlf_MB &#8211; </strong>The biggest virtual log file in MB.</p>
<p><strong>smallest_vlf_MB &#8211; </strong>The smallest virtual log file in MB.</p>
<pre>Database	Vlf_count	biggest_vlf_MB	smallest_vlf_MB
msdb		26		0.4453125	0.2421875
master		5		0.25		0.2421875
model		3		0.25		0.2421875
tempdb		2		0.25		0.2421875
ft_test		2		0.3125		0.2421875</pre>
<p><strong>UPDATE: </strong>Just found a <a href="http://sqlserverpedia.com/blog/sql-server-bloggers/find-the-number-of-vlfs-for-all-databases/">very similar post here</a>.</p>
<p><strong>UPDATE: </strong>Thought I&#8217;d try to bring something to the table and come up with a pure-powershell way to do this but it doesn&#8217;t seem that the VLF information is exposed;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1358code24'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p135824"><td class="code" id="p1358code24"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$server</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;localhost&quot;</span>;
<span style="color: #008000;"># Load SMO </span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadWithPartialName</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Microsoft.SqlServer.Smo&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>; 
<span style="color: #008000;"># create server objects </span>
<span style="color: #800080;">$srv</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Microsoft.SqlServer.Management.SMO.Server <span style="color: #800080;">$server</span>;
<span style="color: #800080;">$db</span> <span style="color: pink;">=</span> <span style="color: #800080;">$srv</span>.Databases<span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;tempdb&quot;</span><span style="color: #000000;">&#93;</span>;
&nbsp;
<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$log</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$db</span>.LogFiles<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$log</span>.Name;
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;=================&quot;</span>;
	<span style="color: #008000;"># Output each property</span>
	<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$p</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$log</span>.Properties<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$p</span>.Name;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Exposed logfile properties&#8230;</p>
<pre>
templog
=================
FileName
Growth
GrowthType
ID
MaxSize
Size
UsedSpace
BytesReadFromDisk
BytesWrittenToDisk
IsOffline
IsReadOnly
IsReadOnlyMedia
IsSparse
NumberOfDiskReads
NumberOfDiskWrites
PolicyHealthState
VolumeFreeSpace
</pre>
<p>If anyone knows a way I&#8217;d be interested to hear. Cheers</p>
<p><map name='google_ad_map_1358_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1358?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1358_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1358&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Faudit-vlfs-on-your-sql-server%2F1358' title="Audit VLFs on your SQL Server" alt=" Audit VLFs on your SQL Server" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358">Audit VLFs on your SQL Server</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/audit-vlfs-on-your-sql-server/1358/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Check for bad SQL Server login passwords</title>
		<link>http://www.youdidwhatwithtsql.com/check-bad-sql-server-login-passwords/1283</link>
		<comments>http://www.youdidwhatwithtsql.com/check-bad-sql-server-login-passwords/1283#comments</comments>
		<pubDate>Mon, 01 Aug 2011 13:28:00 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[PWDCOMPARE]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql login]]></category>
		<category><![CDATA[TSQL]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/check-for-bad-sql-server-login-passwords/1283</guid>
		<description><![CDATA[The PWDCOMPARE function is really handy for further securing your SQL Servers by checking for a range of blank or common passwords. If you google for common password list you&#8217;ll probably recognise several if you&#8217;ve been working in IT for any reasonable amount of time. Fortunately you can use this function, in conjunction with the [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/check-bad-sql-server-login-passwords/1283">Check for bad SQL Server login passwords</a></p>
]]></description>
			<content:encoded><![CDATA[<p>The <a title="TSQL PWDCOMPARE Function" href="http://msdn.microsoft.com/en-us/library/dd822792.aspx" target="_blank">PWDCOMPARE</a> function is really handy for further securing your SQL Servers by checking for a range of blank or common passwords. If you google for <a title="Common password list" href="http://www.google.co.uk/search?rlz=1C1SVEC_enGB381GB381&amp;aq=f&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=common+password+list" target="_blank">common password list</a> you&#8217;ll probably recognise several if you&#8217;ve been working in IT for any reasonable amount of time. Fortunately you can use this function, in conjunction with the <a title="sys.sql_logins system view" href="http://msdn.microsoft.com/en-us/library/ms174355.aspx" target="_blank">sys.sql_logins</a> view, to check an instance for bad passwords.</p>
<p>I&#8217;m only checking <a title="Ten common passwords" href="http://modernl.com/article/top-10-most-common-passwords" target="_blank">ten common passwords</a> with the addition of a blank one. The list is based on a study of UK passwords so it&#8217;s not going to suitable for all corners of the globe. For a live system check you&#8217;ll probably want to use a more comprehensive list of passwords.</p>
<p>This TSQL will list any sql logins with a bad password.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1283code26'); return false;">View Code</a> TSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p128326"><td class="code" id="p1283code26"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">DECLARE</span> @passwords <span style="color: #0000FF;">TABLE</span>
<span style="color: #808080;">&#40;</span>
	pwd <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">100</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> @passwords
<span style="color: #808080;">&#40;</span>
	pwd
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'thomas'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'arsenal'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'monkey'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'charlie'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'qwerty'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'123456'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'letmein'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'liverpool'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'password'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">'123'</span>
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #FF0000;">''</span>;
&nbsp;
<span style="color: #008080;">-- List bad users</span>
<span style="color: #0000FF;">SELECT</span> l.<span style="color: #808080;">&#91;</span>name<span style="color: #808080;">&#93;</span>,
	   l.<span style="color: #808080;">&#91;</span>sid<span style="color: #808080;">&#93;</span>,
	   p.<span style="color: #202020;">pwd</span>
<span style="color: #0000FF;">FROM</span> sys.<span style="color: #202020;">sql_logins</span> l
<span style="color: #0000FF;">INNER</span> <span style="color: #808080;">JOIN</span> @passwords p
	<span style="color: #0000FF;">ON</span> PWDCOMPARE<span style="color: #808080;">&#40;</span>p.<span style="color: #202020;">pwd</span>, l.<span style="color: #202020;">password_hash</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #000;">1</span>;</pre></td></tr></table></div>

<p>Hopefully you&#8217;ll get no results from your check but if you do it may look something like this;</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/Using-the-PWDCOMPARE-function-to-search-_C553/tsql_pwdcompare_sql_login_bad_password.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="tsql_pwdcompare_sql_login_bad_password" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/Using-the-PWDCOMPARE-function-to-search-_C553/tsql_pwdcompare_sql_login_bad_password_thumb.png" alt="tsql pwdcompare sql login bad password thumb Check for bad SQL Server login passwords" width="644" height="164" border="0" /></a></p>
<p><map name='google_ad_map_1283_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1283?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1283_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1283&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fcheck-bad-sql-server-login-passwords%2F1283' title="Check for bad SQL Server login passwords" alt=" Check for bad SQL Server login passwords" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/check-bad-sql-server-login-passwords/1283">Check for bad SQL Server login passwords</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/check-bad-sql-server-login-passwords/1283" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/check-bad-sql-server-login-passwords/1283/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS in a Failover Cluster: Failed to retrieve data for this request</title>
		<link>http://www.youdidwhatwithtsql.com/ssis-failover-cluster-failed-retrieve-data-request/1319</link>
		<comments>http://www.youdidwhatwithtsql.com/ssis-failover-cluster-failed-retrieve-data-request/1319#comments</comments>
		<pubDate>Mon, 01 Aug 2011 11:22:52 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/?p=1319</guid>
		<description><![CDATA[I got this error when attempting to expand the msdb ssis package store on my recently built test cluster; &#34;Failed to retrieve data for this request. Additional information: The SQL Server instance specified in SSIS service configuration is not present or available. This might occur when there is no default instance of SQL Server on [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/ssis-failover-cluster-failed-retrieve-data-request/1319">SSIS in a Failover Cluster: Failed to retrieve data for this request</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I got this error when attempting to expand the <a title="msdb ssis package store" href="http://msdn.microsoft.com/en-us/library/ms137565.aspx" target="_blank">msdb ssis package store</a> on my recently built test cluster;</p>
<p><em>&quot;Failed to retrieve data for this request.</em></p>
<p><em><strong>Additional information: </strong></em></p>
<p><em>The SQL Server instance specified in SSIS service configuration is not present or available. This might occur when there is no default instance of SQL Server on the computer.&quot;</em></p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/SSIS-in-a-Failover-Cluster-Failed-to-ret_125DA/ssis_cluster_error.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="ssis_cluster_error" border="0" alt="ssis cluster error thumb SSIS in a Failover Cluster: Failed to retrieve data for this request" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/SSIS-in-a-Failover-Cluster-Failed-to-ret_125DA/ssis_cluster_error_thumb.png" width="644" height="348" /></a></p>
<p>We need to alter the ssis configuration file, when working in a clustered SQL Server environment, as the service is unable to find an instance of SQL to connect to. The default location of this file is <strong>C:\Program Files\Microsoft SQL Server\100\DTS\Binn\MsDtsSrvr.ini.xml. </strong>open the file and you will see something like below&#8230;</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/SSIS-in-a-Failover-Cluster-Failed-to-ret_125DA/conf1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="conf1" border="0" alt="conf1 thumb SSIS in a Failover Cluster: Failed to retrieve data for this request" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/SSIS-in-a-Failover-Cluster-Failed-to-ret_125DA/conf1_thumb.png" width="644" height="122" /></a></p>
<p>Change the value of <strong>ServerName</strong> to your SQL Server clustered instance name.</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/SSIS-in-a-Failover-Cluster-Failed-to-ret_125DA/conf2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="conf2" border="0" alt="conf2 thumb SSIS in a Failover Cluster: Failed to retrieve data for this request" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2011/SSIS-in-a-Failover-Cluster-Failed-to-ret_125DA/conf2_thumb.png" width="644" height="126" /></a></p>
<p>This step should be repeated on any other nodes where SSIS is running.</p>
<p><map name='google_ad_map_1319_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1319?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1319_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1319&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fssis-failover-cluster-failed-retrieve-data-request%2F1319' title="SSIS in a Failover Cluster: Failed to retrieve data for this request" alt=" SSIS in a Failover Cluster: Failed to retrieve data for this request" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/ssis-failover-cluster-failed-retrieve-data-request/1319">SSIS in a Failover Cluster: Failed to retrieve data for this request</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/ssis-failover-cluster-failed-retrieve-data-request/1319" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/ssis-failover-cluster-failed-retrieve-data-request/1319/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Identify the Active Cluster Node with Powershell</title>
		<link>http://www.youdidwhatwithtsql.com/identify-active-cluster-node-powershell/1315</link>
		<comments>http://www.youdidwhatwithtsql.com/identify-active-cluster-node-powershell/1315#comments</comments>
		<pubDate>Tue, 26 Jul 2011 13:24:26 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Failover Clustering]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/?p=1315</guid>
		<description><![CDATA[I wanted to find a way of programatically identifying the active node of a SQL Server Cluster. I found this post that demonstrated how to do it with TSQL. As I love Powershell so much here&#8217;s another method to do it; ?View Code POWERSHELL# Set cluster name $cluster_name = &#34;ClusterName&#34;; # Load SMO extension &#91;System.Reflection.Assembly&#93;::LoadWithPartialName&#40;&#34;Microsoft.SqlServer.Smo&#34;&#41; [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/identify-active-cluster-node-powershell/1315">Identify the Active Cluster Node with Powershell</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I wanted to find a way of programatically identifying the active node of a SQL Server Cluster. I found this post that demonstrated <a href="http://sql.richarddouglas.co.uk/archive/2010/03/identifying-the-active-cluster-node.html" target="_blank">how to do it with TSQL</a>. As I love <a title="Windows Powershell" href="http://en.wikipedia.org/wiki/Windows_PowerShell" target="_blank">Powershell</a> so much here&#8217;s another method to do it;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1315code28'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p131528"><td class="code" id="p1315code28"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Set cluster name </span>
<span style="color: #800080;">$cluster_name</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;ClusterName&quot;</span>;
<span style="color: #008000;"># Load SMO extension</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadWithPartialName</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Microsoft.SqlServer.Smo&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">out-null</span>;
<span style="color: #800080;">$srv</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> <span style="color: #800000;">&quot;Microsoft.SqlServer.Management.Smo.Server&quot;</span> <span style="color: #800080;">$cluster_name</span>;
<span style="color: #008000;"># Get server properties</span>
<span style="color: #800080;">$properties</span> <span style="color: pink;">=</span> <span style="color: #800080;">$srv</span>.Properties
<span style="color: #800080;">$owner_node</span> <span style="color: pink;">=</span> <span style="color: #800080;">$properties</span>.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;ComputerNamePhysicalNetBIOS&quot;</span><span style="color: #000000;">&#41;</span>.Value;
<span style="color: #800080;">$is_clustered</span> <span style="color: pink;">=</span> <span style="color: #800080;">$properties</span>.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;IsClustered&quot;</span><span style="color: #000000;">&#41;</span>.Value
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$is_clustered</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;The current active node of $cluster_name is $owner_node.&quot;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;$cluster_name is not a clustered instance of SQL Server.&quot;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Execute against your cluster and it will tell you which is the current active node.</p>
<pre>The current active node of ClusterName is Node1.</pre>
<p>It will also tell you if the instance you&#8217;re executing against isn&#8217;t a cluster.</p>
<pre>NotACluster is not a clustered instance of SQL Server.</pre>
<p><map name='google_ad_map_1315_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1315?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1315_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1315&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fidentify-active-cluster-node-powershell%2F1315' title="Identify the Active Cluster Node with Powershell" alt=" Identify the Active Cluster Node with Powershell" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/identify-active-cluster-node-powershell/1315">Identify the Active Cluster Node with Powershell</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/identify-active-cluster-node-powershell/1315" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/identify-active-cluster-node-powershell/1315/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

