<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>get-admin</title>
	
	<link>http://get-admin.com/blog</link>
	<description>Lessons of a Datacenter Administrator</description>
	<lastBuildDate>Sat, 15 Oct 2011 04:17:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Get-admin" /><feedburner:info uri="get-admin" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>PowerCLI: Balance LUN paths for a Cluster</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/1cY_HHHYDDE/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/powercli-balance-lun-paths-for-a-cluster/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 04:17:48 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1333</guid>
		<description><![CDATA[As I&#8217;ve been managing more and more infrastructures using fibre channel storage, I&#8217;ve found that it&#8217;s been somewhat difficult to keep the LUN paths to each host balanced. By balanced, I mean that for each LUN to each host, there is a number of paths and I want to make sure that, for example, each [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowercli-balance-lun-paths-for-a-cluster%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowercli-balance-lun-paths-for-a-cluster%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>As I&#8217;ve been managing more and more infrastructures using fibre channel storage, I&#8217;ve found that it&#8217;s been somewhat difficult to keep the LUN paths to each host balanced.  By balanced, I mean that for each LUN to each host, there is a number of paths and I want to make sure that, for example, each LUN 10 to each of the hosts is using path A as the primary and path B as the stand by.  LUN 11 uses path B as the primary, LUN 12 back to path A, and so on.</p>
<p>It so happens that I&#8217;m using a DMX-4 for storage, and the policy we have is to use a fixed path policy.  I realize that Round Robin would make this entire script moot, well, except for making sure that the PSP is correct.  I also realize that PowerPath would be the ideal solution for EMC storage, but we don&#8217;t use it&#8230;that&#8217;s a story for another day.</p>
<p>This script is, admittedly, long&#8230;longer than I expected it to be.  The original inspiration for this script came from <a href="http://vmjunkie.wordpress.com/2009/01/29/balancing-lun-paths-on-your-esx-hosts-with-powershell/">Justin Emerson&#8217;s very functional and succinct script</a>, however I was not satisfied with the way LUNs were balanced.  His script queries the host for LUNs then sorts them by canonical name and round robins the paths based on the number of paths present for the first LUN.</p>
<p>This works well, so long as all the LUNs are present on all the hosts and they all have the same number of paths.  I can only presume that he assumes that those cases have already been checked for, and fixed, prior to execution.  I wanted to do that all in one script. </p>
<p>Additionally, and it&#8217;s rather petty, I wanted the LUNs to be balanced based off their LUN identifier rather than the canonical name&#8230;they don&#8217;t always follow the same order, and in the case of my hosts with two HBAs (and consequentially, two paths per LUN), I wanted all odd LUNs to use one path for the primary and all even LUNs to use the other.  Justin&#8217;s script does an excellent job of ensuring that the paths are evenly distributed, as you will end up with the same number on each, but not in the pretty fashion I desired.</p>
<p>Also, thank you to Glenn, who helped me &#8220;powershellize&#8221; this script&#8230;my PowerShell looks and reads like Perl, and therefore doesn&#8217;t use a lot of the optimizations that PoSH brings&#8230;such as automatic parameter handling and other niceties.</p>
<p>So, without further ado&#8230;</p>
<p><span id="more-1333"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>cmdletbinding<span style="color: #000000;">&#40;</span>SupportsShouldProcess<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0000FF;">Param</span><span style="color: #000000;">&#40;</span>
    <span style="color: #008000;"># name of the cluster to modify</span>
    <span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: pink;">,</span> ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipelineByPropertyName<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$clusterName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Cluster_01&quot;</span>
<span style="color: pink;">,</span>
    <span style="color: #008000;"># the multipath policy to set for LUNs. be careful with RoundRobin though...it requires some extra params for the Set-ScsiLun command</span>
    <span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: pink;">,</span> ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipelineByPropertyName<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #000000;">&#91;</span>ValidateSet<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Fixed&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;RoundRobin&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;MostRecentlyUsed&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$multipathPolicy</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Fixed&quot;</span>
<span style="color: #000000;">&#41;</span> 
Process
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;Getting list of hosts to check/modify...&quot;</span>
    Try
    <span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$clusters</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: pink;">-</span>ViewType ClusterComputeResource <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span><span style="color: #800000;">'Name'</span><span style="color: pink;">=</span><span style="color: #800080;">$clusterName</span><span style="color: #000000;">&#125;</span> <span style="color: #008080; font-style: italic;">-Property</span> Name<span style="color: pink;">,</span>Hosts
    <span style="color: #000000;">&#125;</span>
    Catch
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot; cluster $clustername not found&quot;</span>
        <span style="color: #0000FF;">return</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Try
    <span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$hosts</span> <span style="color: pink;">=</span> <span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$c</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Clusters</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$c</span>.Host <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">ForEach-Object</span> <span style="color: #000000;">&#123;</span> Get<span style="color: pink;">-</span>VIObjectByVIView <span style="color: #000080;">$_</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #800080;">$hosts</span> <span style="color: pink;">=</span> <span style="color: #800080;">$hosts</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Name</span>
    <span style="color: #000000;">&#125;</span>
    Catch
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;Error enumerating hosts in $clusterName &quot;</span>
        <span style="color: #0000FF;">return</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$hosts</span>.Count <span style="color: #FF0000;">-lt</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span> 
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;No hosts were found in cluster $clustername &quot;</span>
        <span style="color: #0000FF;">return</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008000;"># determine the LUNs available</span>
    <span style="color: #008080; font-weight: bold;">Write-verbose</span> <span style="color: #800000;">&quot;Determing LUNs and paths based on $($hosts[0].Name)&quot;</span>
&nbsp;
    <span style="color: #008000;"># get the LUN order based on the first host</span>
    <span style="color: #800080;">$hostView</span> <span style="color: pink;">=</span> <span style="color: #800080;">$hosts</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.ExtensionData
    <span style="color: #800080;">$storageView</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #800080;">$hostView</span>.ConfigManager.StorageSystem
    <span style="color: #800080;">$hbas</span> <span style="color: pink;">=</span> <span style="color: #800080;">$storageView</span>.StorageDeviceInfo.ScsiTopology.Adapter <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>.Adapter <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;*FibreChannelHba*&quot;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #800080;">$lunList</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
    <span style="color: #800080;">$lunCnames</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$hba</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$hbas</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Key<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$target</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$hba</span>.Target <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Key<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
            <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$lun</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$target</span>.Lun <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Lun<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
                <span style="color: #800080;">$l</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> PSObject <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>
                    Target <span style="color: pink;">=</span> <span style="color: #800080;">$target</span>.Key.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;-&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">2</span><span style="color: #000000;">&#93;</span>
                    Lun <span style="color: pink;">=</span> <span style="color: #800080;">$lun</span>.Lun
                    ScsiLun <span style="color: pink;">=</span> <span style="color: #800080;">$lun</span>.ScsiLun
                    CanonicalName <span style="color: pink;">=</span> $<span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>ScsiLun <span style="color: pink;">-</span>VmHost <span style="color: #800080;">$hosts</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: #008080; font-style: italic;">-Key</span> <span style="color: #800080;">$lun</span>.ScsiLun<span style="color: #000000;">&#41;</span>.CanonicalName
                    Name <span style="color: pink;">=</span> <span style="color: #800080;">$l</span>.Target<span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$l</span>.Lun
                <span style="color: #000000;">&#125;</span>
                <span style="color: #008080; font-weight: bold;">Write-verbose</span> <span style="color: #800000;">&quot;Found LUN $($l.Name)&quot;</span>
&nbsp;
                <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$lunCnames</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$l</span>.CanonicalName<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                    <span style="color: #800080;">$lunCnames</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$l</span>.CanonicalName<span style="color: #000000;">&#93;</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$lunList</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$l</span>.Target<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                    <span style="color: #800080;">$lunList</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$l</span>.Target<span style="color: #000000;">&#93;</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #800080;">$lunList</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$l</span>.Target<span style="color: #000000;">&#93;</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$l</span>
                <span style="color: #800080;">$lunCnames</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$l</span>.CanonicalName<span style="color: #000000;">&#93;</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$l</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #800080;">$lunOrder</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #008000;"># by sorting these two hashes before looping, we end up with the LUNs being in C:T:L order</span>
    <span style="color: #800080;">$lunList</span>.GetEnumerator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Name <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
        <span style="color: #000080;">$_</span>.Value <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Lun <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
            <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$lunOrder</span> <span style="color: #FF0000;">-contains</span> <span style="color: #000080;">$_</span>.CanonicalName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                <span style="color: #008000;"># since it's sorted, we can simply add to an array and it will retain the order</span>
                <span style="color: #800080;">$lunOrder</span> <span style="color: pink;">+=</span> <span style="color: #000080;">$_</span>.CanonicalName
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
    <span style="color: #800080;">$lunFinal</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
    <span style="color: #800080;">$lunPathCount</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008000;"># now that we have the LUN C:T:L order, we simply round robin the avail paths</span>
    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$cn</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$lunOrder</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$lun</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ScsiLun <span style="color: pink;">-</span>VmHost <span style="color: #800080;">$hosts</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">-</span>CanonicalName <span style="color: #800080;">$cn</span>
        <span style="color: #800080;">$paths</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ScsiLunPath <span style="color: pink;">-</span>ScsiLun <span style="color: #800080;">$lun</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> SanID
        <span style="color: #800080;">$x</span> <span style="color: pink;">=</span> <span style="color: #800080;">$i</span> <span style="color: pink;">%</span> <span style="color: #800080;">$paths</span>.Count
        <span style="color: #800080;">$path</span> <span style="color: pink;">=</span> <span style="color: #800080;">$paths</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$x</span><span style="color: #000000;">&#93;</span>
&nbsp;
        <span style="color: #008000;"># the hash will store them in random order, but we don't care cause the path to use</span>
        <span style="color: #008000;"># was determined from the ordered array object...basically, don't be concerned later</span>
        <span style="color: #008000;"># in execution when the report doesn't have each one alternating exactly</span>
        <span style="color: #800080;">$lunFinal</span>.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$cn</span><span style="color: pink;">,</span> <span style="color: #800080;">$path</span>.SanID<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #800080;">$i</span><span style="color: pink;">++</span>
&nbsp;
        <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;Using $($path.SanID) for LUN ${cn} ( $(($lunCnames[$cn] | Sort-Object -Property Name)[0].Name) )&quot;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008000;"># let's check each host to make sure it has the LUNs we found before</span>
    <span style="color: #008000;"># and report on any new or missing LUNs</span>
    <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;Verifying LUNs are on all hosts...&quot;</span>
&nbsp;
    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmhost</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$hosts</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;Checking $($vmhost.Name)&quot;</span>
&nbsp;
        <span style="color: #800080;">$hostLuns</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #800080;">$hostView</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmhost</span>.ExtensionData
&nbsp;
        <span style="color: #008000;"># using the view is faster here and still has the info we want/need</span>
        <span style="color: #008000;"># the where clause on this line will need to be evaluated depending on the environment</span>
        <span style="color: #008000;"># currently I only have EMC arrays, which all LUNs that are *correctly* presented have </span>
        <span style="color: #008000;"># an NAA name.  I don't think all arrays are that way...so this may need to be modified</span>
        <span style="color: #800080;">$hostView</span>.Config.StorageDevice.ScsiLun <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.CanonicalName <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;naa.*&quot;</span> <span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$hostLuns</span> <span style="color: pink;">+=</span> <span style="color: #000080;">$_</span>.CanonicalName
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;"># check for each LUN, remove if found, report if not</span>
        <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$cn</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$lunFinal</span>.GetEnumerator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
        <span style="color: #000000;">&#123;</span>
                <span style="color: #008080; font-weight: bold;">Write-verbose</span> <span style="color: #800000;">&quot;Checking LUN $($cn.Key)&quot;</span>
&nbsp;
            <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$hostLuns</span> <span style="color: #FF0000;">-contains</span> <span style="color: #800080;">$cn</span>.Key<span style="color: #000000;">&#41;</span> 
            <span style="color: #000000;">&#123;</span>
                <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`t</span>LUN found on host&quot;</span>
&nbsp;
                <span style="color: #008000;"># remove the LUN from the array so we know it was found</span>
                <span style="color: #800080;">$hostLuns</span> <span style="color: pink;">=</span> <span style="color: #800080;">$hostLuns</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$cn</span>.Key <span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #008000;"># check for correct number of paths</span>
                <span style="color: #800080;">$pathsOnFirstHost</span> <span style="color: pink;">=</span> $<span style="color: #000000;">&#40;</span><span style="color: #800080;">$lunCnames</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$cn</span>.Key<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>.Count
                <span style="color: #800080;">$pathsOnThisHost</span> <span style="color: pink;">=</span> $<span style="color: #000000;">&#40;</span><span style="color: #800080;">$hostView</span>.Config.StorageDevice.MultipathInfo.Lun <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Lun <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$lunCnames</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$cn</span>.Key<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.ScsiLun <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.Path.Count
&nbsp;
                <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;Found $pathsOnThisHost of $pathsOnFirstHost expected paths for LUN&quot;</span>
&nbsp;
                <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span> <span style="color: #800080;">$pathsOnFirstHost</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$pathsOnThisHost</span><span style="color: #000000;">&#41;</span> 
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-weight: bold;">Write-warning</span> <span style="color: #800000;">&quot;LUN $($cn.Key) does not have expected number of paths ( $pathsOnFirstHost expected, $pathsOnThisHost found )&quot;</span>
                <span style="color: #000000;">&#125;</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-Warning</span> <span style="color: #800000;">&quot;LUN $($cn.Key) was not found on this host&quot;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008000;"># anything left in the array must be unique to the host...e.g. local storage</span>
        <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$hostLuns</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
            <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$cn</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$hostLuns</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                <span style="color: #008080; font-weight: bold;">Write-verbose</span> <span style="color: #800000;">&quot;LUN $($cn) was not found in initial scan and will be ignored!&quot;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008000;"># now we set each host in the cluster to use the determined paths</span>
    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmhost</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$hosts</span><span style="color: #000000;">&#41;</span> 
    <span style="color: #000000;">&#123;</span>
	    <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmhost</span>.ConnectionState <span style="color: #FF0000;">-ne</span> <span style="color: #800000;">&quot;disconnected&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		    <span style="color: #008080; font-weight: bold;">Write-Verbose</span> <span style="color: #800000;">&quot;Starting configuration of $($vmhost.Name)&quot;</span>
&nbsp;
		    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$lunCanonicalName</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$lunFinal</span>.GetEnumerator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
            <span style="color: #000000;">&#123;</span>
			    <span style="color: #800080;">$lun</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmhost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>ScsiLun <span style="color: pink;">-</span>CanonicalName <span style="color: #800080;">$lunCanonicalName</span>.Key
			    <span style="color: #800080;">$path</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ScsiLunPath <span style="color: pink;">-</span>ScsiLun <span style="color: #800080;">$lun</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.SanID <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$lunCanonicalName</span>.Value <span style="color: #000000;">&#125;</span>
&nbsp;
			    <span style="color: #0000FF;">IF</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$PSCmdlet</span>.ShouldProcess<span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMhost</span>.Name<span style="color: pink;">,</span> <span style="color: #800000;">&quot;Setting $($lun.CanonicalName) active/preferred path to $($path.SanID)&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
				    <span style="color: #800080;">$lun</span> <span style="color: pink;">|</span> Set<span style="color: pink;">-</span>ScsiLun <span style="color: pink;">-</span>MultipathPolicy <span style="color: #800080;">$multipathPolicy</span> <span style="color: pink;">-</span>PreferredPath <span style="color: #800080;">$path</span>
&nbsp;
				    <span style="color: #008000;"># this sleep time may need to be adjusted for different arrays</span>
				    <span style="color: #008080; font-weight: bold;">Start-Sleep</span> <span style="color: #008080; font-style: italic;">-Seconds</span> <span style="color: #804000;">3</span>
			    <span style="color: #000000;">&#125;</span>
		    <span style="color: #000000;">&#125;</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-Warning</span> <span style="color: #800000;">&quot;$($vmhost.Name) is disconnected from vCenter&quot;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/Get-admin/~4/1cY_HHHYDDE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/powercli-balance-lun-paths-for-a-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/powercli-balance-lun-paths-for-a-cluster/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powercli-balance-lun-paths-for-a-cluster</feedburner:origLink></item>
		<item>
		<title>PowerCLI: Show HBA Path Status</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/2YxBUVvC60E/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/powercli-show-hba-path-status/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 14:48:49 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1328</guid>
		<description><![CDATA[When you have a lot of hosts, with a lot of LUNs, it can be difficult to keep abreast of the status of the paths for them. I have encountered issues where a path was unknowingly marked as dead, plus it&#8217;s generally a good idea to ensure that your storage paths are actually available. Consequentially, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowercli-show-hba-path-status%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowercli-show-hba-path-status%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When you have a lot of hosts, with a lot of LUNs, it can be difficult to keep abreast of the status of the paths for them.  I have encountered issues where a path was unknowingly marked as dead, plus it&#8217;s generally a good idea to ensure that your storage paths are actually available.</p>
<p>Consequentially, I searched for a PowerCLI script that would give me a simple report of the status of each of the LUN paths to each of the HBAs on my hosts.  I found <a href="http://jfrmilner.wordpress.com/2011/08/27/checking-for-dead-paths-on-hbas-with-powercli/">John Milner&#8217;s post</a> to be very helpful, and it gave me exactly the results that I wanted.  However, it took forever to execute&#8230;almost 30 minutes for just one of my clusters (to be fair, that cluster has 12 hosts with > 100 LUNs and two paths to each).</p>
<p>Using his script as an example, and keeping a good bit of the formatting code, I have modified his script to use views of the host objects and cull the information from there.  This makes it significantly faster&#8230;what took 28 minutes before now takes about 30 seconds.</p>
<p><span id="more-1328"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$views</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: pink;">-</span>ViewType <span style="color: #800000;">&quot;HostSystem&quot;</span> <span style="color: #008080; font-style: italic;">-Property</span> Name<span style="color: pink;">,</span>Config.StorageDevice
<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$view</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$views</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Name<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;Checking&quot;</span> <span style="color: #800080;">$view</span>.Name
&nbsp;
    <span style="color: #800080;">$view</span>.Config.StorageDevice.ScsiTopology.Adapter <span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Adapter <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;*FibreChannelHba*&quot;</span> <span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$hba</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>.Adapter.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;-&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">2</span><span style="color: #000000;">&#93;</span>
&nbsp;
        <span style="color: #800080;">$active</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
        <span style="color: #800080;">$standby</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
        <span style="color: #800080;">$dead</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
        <span style="color: #000080;">$_</span>.Target <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span> 
            <span style="color: #000080;">$_</span>.Lun <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span>
                <span style="color: #800080;">$id</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>.ScsiLun
&nbsp;
                <span style="color: #800080;">$multipathInfo</span> <span style="color: pink;">=</span> <span style="color: #800080;">$view</span>.Config.StorageDevice.MultipathInfo.Lun <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Lun <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$id</span> <span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #800080;">$a</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">ARRAY</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$multipathInfo</span>.Path <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.PathState <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;active&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #800080;">$s</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">ARRAY</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$multipathInfo</span>.Path <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.PathState <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;standby&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #800080;">$d</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">ARRAY</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$multipathInfo</span>.Path <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.PathState <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;dead&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
&nbsp;
                <span style="color: #800080;">$active</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$a</span>.Count
                <span style="color: #800080;">$standby</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$s</span>.Count
                <span style="color: #800080;">$dead</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$d</span>.Count
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #800080;">$result</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;{0},{1},{2},{3},{4}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$view</span>.Name.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span><span style="color: pink;">,</span> <span style="color: #800080;">$hba</span><span style="color: pink;">,</span> <span style="color: #800080;">$active</span><span style="color: pink;">,</span> <span style="color: #800080;">$dead</span><span style="color: pink;">,</span> <span style="color: #800080;">$standby</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
ConvertFrom<span style="color: pink;">-</span>Csv <span style="color: pink;">-</span>Header <span style="color: #800000;">&quot;VMHost&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;HBA&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;Active&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;Dead&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;Standby&quot;</span> <span style="color: #008080; font-style: italic;">-InputObject</span> <span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">ft</span> <span style="color: #008080; font-style: italic;">-AutoSize</span></pre></div></div>

<p>The result looks exactly like the original:</p>
<pre>VMHost HBA    Active Dead Standby
------ ---    ------ ---- -------
host1  vmhba1 9      0    9
host1  vmhba2 9      0    9
host2  vmhba1 9      0    9
host2  vmhba2 9      0    9
host3  vmhba1 9      0    9
host3  vmhba2 9      0    9
host4  vmhba1 9      0    9
host4  vmhba2 9      0    9
host5  vmhba1 9      0    9
host5  vmhba2 9      0    9
host6  vmhba1 9      0    9
host6  vmhba2 9      0    9
host7  vmhba1 9      0    9
host7  vmhba2 9      0    9
host8  vmhba1 10     0    10
host8  vmhba2 10     0    10 </pre>
<p>This is also helpful, for me, because each of my hosts should have the same number of active and standby paths&#8230;if there is more of one or the other, that&#8217;s an indication that a path is missing, or there is an extra for some reason.  For example, the above is a single cluster, so they should all be identical.  Multipathing appears to be good because there are the same number of active and standby paths.  However, one host has an extra pair of paths&#8230;a simple check revealed that an old LUN had not been removed&#8230;no damage done, but very easy to spot with this script.</p>
<p>Thanks to <a href="http://jfrmilner.wordpress.com/">John</a> for doing all the hard work with formatting!</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/2YxBUVvC60E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/powercli-show-hba-path-status/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/powercli-show-hba-path-status/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powercli-show-hba-path-status</feedburner:origLink></item>
		<item>
		<title>Atlanta PowerShell User Group</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/354_Qi7qO-k/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/atlanta-powershell-user-group/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 13:00:43 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1319</guid>
		<description><![CDATA[Last week I had the pleasure of presenting to the Atlanta PowerShell User Group.  The presentation was available over live meeting, if you missed it the recording can be found below.  The scripts used in this presentation can also be downloaded here.  Note we had a little problem getting the audio working so fast forward [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fatlanta-powershell-user-group%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fatlanta-powershell-user-group%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week I had the pleasure of presenting to the Atlanta PowerShell User Group.  The presentation was available over live meeting, if you missed it the recording can be found below.  The scripts used in this presentation can also be downloaded <a href="http://get-admin.com/blog/wp-content/uploads/2011/08/ATL_PUG.zip">here</a>.  Note we had a little problem getting the audio working so fast forward to the 2:00 minute mark.<br />
<iframe src="http://player.vimeo.com/video/27975503?title=0&amp;byline=0&amp;portrait=0" frameborder="0" width="400" height="300"></iframe></p>
<p><a href="http://vimeo.com/27975503">Atlanta PowerShell User Group August 2011</a> from <a href="http://vimeo.com/user8204572">Glenn Sizemore</a>.</p>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/354_Qi7qO-k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/atlanta-powershell-user-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/atlanta-powershell-user-group/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=atlanta-powershell-user-group</feedburner:origLink></item>
		<item>
		<title>Perl Toolkit: Check ESX(i) host time</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/Ts1hz9rnVn4/</link>
		<comments>http://get-admin.com/blog/how-to/vmware/esx-vmware-how-to/perl-toolkit-check-esxi-host-time/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 02:04:07 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[ESX]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1315</guid>
		<description><![CDATA[I had an issue recently where a single ESXi host&#8217;s clock was incorrect. The administrator had never set the clock initially, so NTP never kept it in sync cause it was too far off to begin. Since I&#8217;ve got a large number of hosts and the idea of clicking to each one through VI Client [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fhow-to%2Fvmware%2Fesx-vmware-how-to%2Fperl-toolkit-check-esxi-host-time%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fhow-to%2Fvmware%2Fesx-vmware-how-to%2Fperl-toolkit-check-esxi-host-time%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I had an issue recently where a single ESXi host&#8217;s clock was incorrect.  The administrator had never set the clock initially, so NTP never kept it in sync cause it was too far off to begin.</p>
<p>Since I&#8217;ve got a large number of hosts and the idea of clicking to each one through VI Client and checking the configuration tab, I immediately turned to PowerCLI.  Naturally, one of <a href="http://www.lucd.info/">Luc</a>&#8216;s <a href="http://communities.vmware.com/message/1732818#1732818">scripts</a> was the top search result.  </p>
<p>That solved my immediate need to check the hosts, but I also wanted to setup some general monitoring.  Since my monitoring infrastructure is compromised, primarily, of a linux Nagios host, that means PowerCLI couldn&#8217;t help.  So, I did the next best thing and ported Luc&#8217;s script to perl.</p>
<p>Below is the result of that porting.  It can also be run from vMA for reporting via email or another mechanism.</p>
<p><span id="more-1315"></span></p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># vi-check-host-time.pl - written by Andrew Sullivan, 2011-08-17</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Please report bugs and request improvements at http://get-admin.com/blog/uncategorized/perl-toolkit-check-esxi-host-time/</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># A perl port of LucD's script for checking the time of an ESX(i) host against</span>
<span style="color: #666666; font-style: italic;"># the localhost to check for drift.  The original can be found here:</span>
<span style="color: #666666; font-style: italic;"># http://communities.vmware.com/message/1732818#1732818</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Examples:</span>
<span style="color: #666666; font-style: italic;">#   Check all hosts connected to a vCenter server</span>
<span style="color: #666666; font-style: italic;">#   ./vi-check-host-time.pl --server your.vi.server</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   Check a specific host</span>
<span style="color: #666666; font-style: italic;">#   ./vi-check-host-time.pl --server some.esxi.host</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> FindBin<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> lib <span style="color: #ff0000;">&quot;$FindBin::Bin/../&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> VMware<span style="color: #339933;">::</span><span style="color: #006600;">VIRuntime</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">Local</span><span style="color: #339933;">;</span>
&nbsp;
Opts<span style="color: #339933;">::</span><span style="color: #006600;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Opts<span style="color: #339933;">::</span><span style="color: #006600;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Util<span style="color: #339933;">::</span><span style="color: #000066;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># number of seconds that is tolerable for drift</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$allowedDrift</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get only hosts that are connected to vCenter, get only the name and dateTimeSystem MOR</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hosts</span> <span style="color: #339933;">=</span> Vim<span style="color: #339933;">::</span><span style="color: #006600;">find_entity_views</span><span style="color: #009900;">&#40;</span> 
		view_type <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'HostSystem'</span><span style="color: #339933;">,</span>
		filter <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #ff0000;">'summary.runtime.connectionState'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;connected&quot;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		properties <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span> <span style="color: #ff0000;">'summary.config.name'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'configManager.dateTimeSystem'</span> <span style="color: #009900;">&#93;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$host</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$hosts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># get the date of the system and all the parts so we can convert to epoch time</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dts</span> <span style="color: #339933;">=</span> Vim<span style="color: #339933;">::</span><span style="color: #006600;">get_view</span><span style="color: #009900;">&#40;</span> mo_ref <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$host</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_property</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'configManager.dateTimeSystem'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hosttime</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dts</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">QueryDateTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$year</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$month</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$day</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$minutes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$seconds</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$hosttime</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/(\d{4})\-(\d{2})\-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})\.*/</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># do the convertion to epoch time</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hostepoch</span> <span style="color: #339933;">=</span> timegm<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$seconds</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$minutes</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$day</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$month</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$year</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1900</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># get the epoch time for the local system</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$localtime</span> <span style="color: #339933;">=</span> <span style="color: #000066;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># check for drift, output something</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hostepoch</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$localtime</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$allowedDrift</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #0000ff;">$host</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_property</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'summary.config.name'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot; is &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hostepoch</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$localtime</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot; seconds off! <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #0000ff;">$host</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_property</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'summary.config.name'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot; is within allowable drift <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
Util<span style="color: #339933;">::</span><span style="color: #006600;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/Get-admin/~4/Ts1hz9rnVn4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/how-to/vmware/esx-vmware-how-to/perl-toolkit-check-esxi-host-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/how-to/vmware/esx-vmware-how-to/perl-toolkit-check-esxi-host-time/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=perl-toolkit-check-esxi-host-time</feedburner:origLink></item>
		<item>
		<title>NetApp PowerGUI PowerPack, the inside story.</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/AU1q_QF1zwQ/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/netapp-powergui-powerpack-the-inside-story/#comments</comments>
		<pubDate>Fri, 13 May 2011 12:44:13 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerGUI]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1300</guid>
		<description><![CDATA[My NetApp fanboyism is fairly well established at this point.  I devoted almost three years to developing a PowerShell module that would teach NetApp how PowerShell worked.  To my delight a year ago at TechED they took the storage world by surprise when they shipped an official module.  I was then humbled to learn that [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fnetapp-powergui-powerpack-the-inside-story%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fnetapp-powergui-powerpack-the-inside-story%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>My NetApp fanboyism is fairly well established at this point.  I devoted almost three years to developing a PowerShell module that would teach NetApp how PowerShell worked.  To my delight a year ago at TechED they took the storage world by surprise when they shipped an official module.  I was then humbled to learn that they had found PoshONTAP, and used it as a blueprint when developing the DataONTAP PowerShell toolkit.  This experience taught me a valuable lesson.  If you believe in something&#8230; just do it&#8230; life has a funny way of sorting it all out.  I took this philosophy an started anew , and my career ski rocketed.  The affirmation of all that work was when NetApp approached me six months ago.  At first I didn&#8217;t believe it was possible, but after many grueling interviews I started to realize I could do this job.  Fast forward two months and I&#8217;m all settled in at NetApp, and LOVING it!  This place is the google of the storage/IT world.  Everywhere you look there is another brilliant engineer, but something was still missing&#8230; The PowerShell toolkit had shipped and was doing fantastic, but PowerShell still wasn&#8217;t in the forefront of developers writing the tools for a windows administrators.  I thought about what I could do, again if you believe in something just do it.  Enter PowerGUI.</p>
<p>A while back Kirk had approached me about writting a PowerPack for NetApp, and I always thought it was a great idea.  So&#8230; I learned, and learned fast.  Turns out a PowerPack is fairly simple to author.  About a week later I had a working demo to show around internally.  I had my position papers worked out, and had the elevator pitch ready.  I was going to hit the streets and sell PowerShell using PowerGUI as my catalysis.  Then something amazing happened, everyone I showed PowerGUI to loved it! Furthermore they instantly knew the advantage of building a tool on top of PowerShell had.  I didn&#8217;t have to sell anything the tool simply sold itself.  At MMS this year if you stopped by during a lull you would have gotten an early alpha demo of the PowerPack.  I gave my boss said demo, and his guidance was clear, SHIP IT!  Over the past month with the help of the whole team, we went through the gambit from legal to marketing, but in the end my secret project shipped yesterday.  What started out as a sales tool ended up being such a compelling user interface that we just couldn&#8217;t keep it to ourselves.</p>
<p>If your a PowerGUI user of just a NetApp customer check out PowerGUI, and the PowerPack, as I think it is quite compelling.<br />
<object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/e-PrAbGvzJA?fs=1&amp;hl=en_US&amp;rel=0" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="425" height="349" src="http://www.youtube.com/v/e-PrAbGvzJA?fs=1&amp;hl=en_US&amp;rel=0" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>~Glenn</p>
<p>Update: There is a known bug in PowerGUI where the first two objects returned don&#8217;t display alias properties, as the DataONTAP Toolkit uses alias&#8217;s heavily many object appear to be blank.  Kirk&#8217;s team know about the issue and are working to fix it.</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/AU1q_QF1zwQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/netapp-powergui-powerpack-the-inside-story/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/netapp-powergui-powerpack-the-inside-story/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=netapp-powergui-powerpack-the-inside-story</feedburner:origLink></item>
		<item>
		<title>PowerShell: 2011 Scripting Games are almost uppon us!</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/afEyEqSv_XA/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/powershell-2011-scripting-games-are-almost-uppon-us/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 13:50:57 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting Games]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1274</guid>
		<description><![CDATA[Grab this badge here! The 2011 Scripting Games are almost upon us, and I for one am very excited.  There will be some modifications made to the games this year.  For one this will be the first year that the games will only be in one language.  This was done for several resons, but they [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowershell-2011-scripting-games-are-almost-uppon-us%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowershell-2011-scripting-games-are-almost-uppon-us%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://blogs.technet.com/heyscriptingguy/archive/tags/2011+Scripting+Games/default.aspx"><img style="display: block; margin: 0px auto; border-width: 0px;" src="http://bit.ly/2011sgbadge" alt="2011 Scripting Games" /></a></p>
<p style="font-size: 80%; text-align: center; margin: 0px;"><a title="2011 Scripting Games--Grab this badge here!" href="http://bit.ly/2011sggrabbadge">Grab this badge here!</a></p>
<p>The 2011 Scripting Games are almost upon us, and I for one am very excited.  There will be some modifications made to the games this year.  For one this will be the first year that the games will only be in one language.  This was done for several resons, but they all boil down to one&#8230;. There is simply no reason to not be using PowerShell at this point!  As a reformed VBScritper I for one welcome the change.</p>
<p>Another modification is that you will only be allowed to enter in one catagory.  There was some heart ache last year, because I participated in every event.  This raised the bar so that anyone who wanted to win would have had to produce 20 scripts in 14 days.  The other side of the coin was that I was unfairly entering scripts that a true beginer shouldn&#8217;t have to compeate against.  Both are valid points, and in hind site perhaps entering in both catagories was a poor choice on my behalf.  That said, I welcome only participating in a single catagory, as delivering two high quality scripts per day for two weeks was a daunting task, and I was burned out after two weeks.</p>
<p>Another potentialy game changing modification is that the submitions may not be visiable until after the deadline for a given challenge.  Again I welcome this change as last years games only had one or two original solutions per event.  By making the submitions private until after the deadline every solution will be original.  This change by it&#8217;s very nature will enable cleaver, and uniqe approaches to a problem.  I don&#8217;t think cheeting was a problem last year, but instead if you saw a script that used a rare .net object, and that script got 5 starts&#8230;. well doesn&#8217;t that influence you to use the same rare .net object yourself?  Of coarse it does, it&#8217;s only human nature to want to deliver the best solution possible.</p>
<p>At the end of the day whether your new to scripting or a seasoned pro I highly encourage you to participate in the games this year.  I for one will attempt to defend my title, but there will be stiff competition, and I will be shocked if I can pull off a back to back championship.  Oh yeah, and did I mention first prize will land you a free pass to TechEd Atlanta!</p>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/afEyEqSv_XA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/powershell-2011-scripting-games-are-almost-uppon-us/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/powershell-2011-scripting-games-are-almost-uppon-us/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-2011-scripting-games-are-almost-uppon-us</feedburner:origLink></item>
		<item>
		<title>I’m famous… well sorta</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/gBM4iZSMeGM/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/im-famous-well-sorta/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 15:11:25 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1288</guid>
		<description><![CDATA[Recently I was asked to do a guest post on the illustrious &#8220;Hey, Scripting Guy!&#8221; blog. I was very happy, and excited by this opportunity, but didn&#8217;t know what to write. I kicked it around for a couple days, and still nothing. So I called an old friend and asked him what his pain points [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fim-famous-well-sorta%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fim-famous-well-sorta%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently I was asked to do a guest post on the illustrious &#8220;<a href="http://blogs.technet.com/b/heyscriptingguy/">Hey, Scripting Guy</a>!&#8221; blog. I was very happy, and excited by this opportunity, but didn&#8217;t know what to write. I kicked it around for a couple days, and still nothing. So I called an old friend and asked him what his pain points were. He informed me that his shop was now operating under a 24&#215;7 operations cycle, and it was impossible to keep his 3000+ workstations patched. With that I had my topic; having worked in these environments before I was acutely aware of the strain they put on the sysadmin to stay compliant. A couple days later I had compiled all the best techniques for detecting if a user was active on his/her PC, and shipped my draft off the scripting guy. This morning Google reader greeted me with my very own post!</p>
<p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/17/use-powershell-to-detect-if-a-workstation-is-in-use.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/17/use-powershell-to-detect-if-a-workstation-is-in-use.aspx</a></p>
<p>Thanks to the Scripting Guy again for this awesome opportunity and I hope you enjoy the post!</p>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/gBM4iZSMeGM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/im-famous-well-sorta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/im-famous-well-sorta/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=im-famous-well-sorta</feedburner:origLink></item>
		<item>
		<title>PowerShell: NetApp DataONTAP toolkit credentials management</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/ZKlp69T8cv8/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/powershell-netapp-dataontap-toolkit-credentials-management/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 13:16:06 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1269</guid>
		<description><![CDATA[I&#8217;ve had the pleasure of spending the last several days talking to the development team here at NetApp about the DataONTAP PowerShell Toolkit.  As a result we&#8217;ve all learned alot, one of the more interesting features they brought to my attention was the credential management solution included with the toolkit.  I found this very compelling, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowershell-netapp-dataontap-toolkit-credentials-management%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowershell-netapp-dataontap-toolkit-credentials-management%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">I&#8217;ve had the pleasure of spending the last several days talking to the development team here at NetApp about the DataONTAP PowerShell Toolkit.  As a result we&#8217;ve all learned alot, one of the more interesting features they brought to my attention was the credential management solution included with the toolkit.  I found this very compelling, you see embedding credentials within a script is as old as scripting itself.  There was a time not too long ago when it was considered taboo.  However with PowerShell came access to the .net Security.Cryptography encryption/decryption methods.  Scripters have unknowingly been accessing said methods indirectly whenever they would use the credential management funcions that <a href="http://poshcode.org/471">Hal</a> amd <a href="http://bsonposh.com/archives/338">BSonPosh </a>wrote long ago.</p>
<p style="text-align: justify;">Which brings me to the DataONTAP toolkit.  The Development team has steped it up a notch and included a full credential management solution with the latest version of the toolkit.  The way it works is first you need to save logon information by using the Add-NaCredential cmdlet to save the credentials for a given NetApp controller onto the local machine.  Then the next time you run the Connect-NaController cmdlet the credentials you previously saved will be used. So how do we use this new feature, and why do you care?</p>
<p><span id="more-1269"></span></p>
<p style="text-align: justify;">First the how, to get started you simply run the Add-NaCredential cmdlet for every Controller you plan on scriptitng against.  Some of you may notice a SystemScope switch, be aware that when you apply this parameter the credentials are saved in the systemscope.  This paramter is intended to be used in situations were you want to grant the SYSTEM account access to the credential store&#8230;. in other words don&#8217;t use it unless told explicitly that it&#8217;s required as this is inhearently less secure. It was included in an attempt to support any possible senerio&#8230;  That said, let&#8217;s add a controller to the local store.</p>
<table border="0" cellspacing="0" cellpadding="2" width="799" bgcolor="#00008b">
<tbody>
<tr>
<td width="797" valign="top">
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:4]&gt;</strong></span> Add-NaCredential -Name SIM01 -Credential root
Name                                    Credential                              HostUser
----                                    ----------                              --------
SIM01                                   System.Management.Automation.PSCrede... GetAdmin\glnsize
</span></span></span></pre>
</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">Now that the credential have been added to the local store you can connect to the target filer without supplying any credential information.</p>
<table border="0" cellspacing="0" cellpadding="2" width="799" bgcolor="#00008b">
<tbody>
<tr>
<td width="797" valign="top">
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:5]&gt;</strong></span> Connect-NaController SIM01
Name                 Address           Ontapi   Version
----                 -------           ------   -------
SIM01                192.168.19.130    1.12     NetApp Release 7.3.4: Thu May 27 15:43:26 PDT 2010
</span></span></span></pre>
</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">From a feature and functionality perspective it&#8217;s the same as using RPC, but will work with any protocol.   Additionaly because there is a proper PSCredential object embeded in the resulting NaController connection object,  you can also use the Invoke-NaSSH cmdlet without supplying any credentials!  Something you cannot do when connected via RPC.  For good measure the team also included a couple cmdlets to manage the contents of the credential store.</p>
<table border="0" cellspacing="0" cellpadding="2" width="799" bgcolor="#00008b">
<tbody>
<tr>
<td width="797" valign="top">
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:6]&gt;</strong></span> Get-NaCredential
Name                                    Credential                              HostUser
----                                    ----------                              --------
SIM01                                   System.Management.Automation.PSCrede... GetAdmin\glnsize
SIM02                                   System.Management.Automation.PSCrede... GetAdmin\glnsize
</span></span></span></pre>
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:7]&gt;</strong></span> Get-NaCredential SIM02 | Remove-NaCredential</span></span></span></span></span></span></pre>
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:8]&gt;</strong></span> Get-NaCredential
Name                                    Credential                              HostUser
----                                    ----------                              --------
SIM01                                   System.Management.Automation.PSCrede... GetAdmin\glnsize</span></span></span></pre>
</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">So weather your connecting on the fly or from within a script using the included credential store can significantly decrese the complexity while incresing the security of administering any NetApp infrastructure from a PowerShell prompt.</p>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/ZKlp69T8cv8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/powershell-netapp-dataontap-toolkit-credentials-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/powershell-netapp-dataontap-toolkit-credentials-management/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-netapp-dataontap-toolkit-credentials-management</feedburner:origLink></item>
		<item>
		<title>PowerShell: A note on Execution policy.</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/kcrD-zaTx4M/</link>
		<comments>http://get-admin.com/blog/scripting/powershell-scripting/powershell-a-note-on-execution-policy/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 01:23:23 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1260</guid>
		<description><![CDATA[While driving up to RTP today I was listening to the PowerScritpting podcast episode 140.  Hal and Johnathan received a question about execution policy settings.  The conclusion they reached was that remote signed was a good compromise.  I would like to expand on this a bit.  The real fear with script execution is that you&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowershell-a-note-on-execution-policy%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fscripting%2Fpowershell-scripting%2Fpowershell-a-note-on-execution-policy%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">While driving up to RTP today I was listening to the <a href="http://powerscripting.wordpress.com/2011/02/20/episode-140-scripting-guy-ed-wilson/">PowerScritpting</a> podcast episode 140.  Hal and Johnathan received a question about execution policy settings.  The conclusion they reached was that remote signed was a good compromise.  I would like to expand on this a bit.  The real fear with script execution is that you&#8217;ll unintentionally run code that has malicious intent buried within it.  Personally I don&#8217;t run around running code before I review and test it, but that doesn&#8217;t mean I&#8217;m safe.  As PowerShell MVP and trainer extraordinaire Don Jones has previously stated the risk is with your profile.</p>
<p style="text-align: justify;"><span id="more-1260"></span></p>
<p>You see your profile is ran automatically, it is triggered by it&#8217;s mear presence.  If script execution is enabled you don&#8217;t even have to create the profile.  A co-worker could simply place one in your $PSHOME directory and powershell WILL run it.  So now that we&#8217;re in the land of malicious intent there isn&#8217;t anything you can do to stop said intent, but you can prove it wasn&#8217;t you.  This is why I have every pc in my domain set to AllSigned, but I then lower the execution policy to RemoteSigned after my profile is finished running.  This way even if someone does maliciously compromise my profile or a module I autoload there are two possible results.</p>
<ol>
<li style="text-align: justify;">The hash will be broken and powershell will not only not run the modified code, but it will also aleart me to the unauthorised modification.</li>
<li style="text-align: justify;">It loads meaning someone has signed it with a valid certificate thereby leaving a forensic trace of the codes origin.</li>
</ol>
<p>Finally, I would highlight that malicious intent isn&#8217;t always something egregious like removing all users in AD.  It&#8217;s often something simple like adding someone to a group there not authorized access to.  Before you run off snickering there is no reason to leave yourself exposed when there is a simple remedy.</p>
<p>First set your execution policy to AllSigned.  Then in your profile after you&#8217;ve loaded everything simply place the following line.</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff;">Set-ExecutionPolicy</span> <span style="color: #000080;">-ExecutionPolicy</span> <span style="color: #8a2be2;">RemoteSigned</span> <span style="color: #000080;">-Scope</span> <span style="color: #8a2be2;">Process</span></pre>
<p>Now you have a best of both worlds scenario, protection for code that powershell runs automatically, and an environment more development friendly!    Admittedly there is still the potential that someone compromises a script or module that you don&#8217;t autoload, but the only remedy there would be to run AllSigned all the time&#8230; and well, if that was easy everyone would do it.</p>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/kcrD-zaTx4M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/scripting/powershell-scripting/powershell-a-note-on-execution-policy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/scripting/powershell-scripting/powershell-a-note-on-execution-policy/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-a-note-on-execution-policy</feedburner:origLink></item>
		<item>
		<title>PowerCLI: Why you need this book!</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/iP8pv-c0Gsk/</link>
		<comments>http://get-admin.com/blog/how-to/vmware/powercli-why-you-need-this-book/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 14:24:47 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Virtulization]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1248</guid>
		<description><![CDATA[The VMware vSphere PowerCLI Reference will officially go on sale April 12th, and if your a vSphere administrator this one is a must have. We gathered the collective automation experience of four vEXPERTS and a MVP, and then filtered it through a fifth vEXPERT. The end result was a collection of polished solutions that are [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fhow-to%2Fvmware%2Fpowercli-why-you-need-this-book%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2Fhow-to%2Fvmware%2Fpowercli-why-you-need-this-book%2F&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;"><a href="http://www.amazon.com/gp/product/0470890797?ie=UTF8&amp;tag=getadmi-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470890797"><img class="alignright size-medium wp-image-1249" title="cover" src="http://get-admin.com/blog/wp-content/uploads/2011/03/cover-300x300.jpg" alt="" width="300" height="335" /></a>The VMware vSphere PowerCLI Reference will officially go on sale April 12th, and if your a vSphere administrator this one is a must have. We gathered the collective automation experience of four vEXPERTS and a MVP, and then filtered it through a fifth vEXPERT. The end result was a collection of polished solutions that are not only technically proficient, but more importantly will work the first time every time! Having all built and maintained large infrastructures we combined our collective knowledge and wrote a complete reference, we cover the entire life cycle from creating your environment to monitoring it long term.  I mean it, we left no stone unturned where VMware had no PowerCLI solution we wrote our own.  This book includes a PowerShell Module with 79 custom advanced functions! We also considered how you would use our book, and chose to take a task driven approach, this enabled you to just flip to the answer you need.  You don&#8217;t have to &#8220;read&#8221; all 780 pages&#8230; instead think of this book as a fire extinguisher for your virtual infrastructure.</p>
<p style="text-align: justify;">So that&#8217;s great, but who needs a book? With blogs and the community forums you can just find the answer right?  Yes, yes you can eventually, but if you do that your shopping at a fishery. In this book we WILL teach you to fish! As a commitment to that end we created a dedicated web site to support our work.  If you find a bug, or if we missed something you can post a question in our forum!</p>
<p style="text-align: justify;">Admittedly this is my first published work, but I couldn&#8217;t be prouder of it.  In my opinion The ONYX, and vSphere SDK chapters alone would be worth the cover price.  I look forward to the release, and to your honest opinions of our work!</p>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/iP8pv-c0Gsk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/how-to/vmware/powercli-why-you-need-this-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/how-to/vmware/powercli-why-you-need-this-book/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powercli-why-you-need-this-book</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.388 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-20 23:31:47 -->

