<?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>Arnim van Lieshout</title>
	
	<link>http://www.van-lieshout.com</link>
	<description>About virtualization and more</description>
	<lastBuildDate>Tue, 31 Jan 2012 13:30:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ArnimVanLieshout" /><feedburner:info uri="arnimvanlieshout" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>PowerCLI automation: Create vCenter Notification Email Alarm Action</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/17xzWdMOiSw/</link>
		<comments>http://www.van-lieshout.com/2012/01/powercli-automation-create-vcenter-notification-email-alarm-action/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 13:30:36 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[vCenter]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1862</guid>
		<description><![CDATA[Need to configure email notifications on vCenter alarms? This PowerCLI automation script will save you valuable time and configure the alarms for you


Related posts:<ol><li><a href='http://www.van-lieshout.com/2010/12/a-new-powercli-release-and-a-new-year%e2%80%99s-feature/' rel='bookmark' title='Permanent Link: A new PowerCLI release and a New Year’s feature'>A new PowerCLI release and a New Year’s feature</a></li>
<li><a href='http://www.van-lieshout.com/2010/05/powercli-disableenable-ha-and-drs/' rel='bookmark' title='Permanent Link: PowerCLI: Disable/Enable HA and DRS'>PowerCLI: Disable/Enable HA and DRS</a></li>
<li><a href='http://www.van-lieshout.com/2011/06/drs-rules/' rel='bookmark' title='Permanent Link: Managing VMware DRS rules using PowerCLI'>Managing VMware DRS rules using PowerCLI</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2012%2F01%2Fpowercli-automation-create-vcenter-notification-email-alarm-action%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2012%2F01%2Fpowercli-automation-create-vcenter-notification-email-alarm-action%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve received a request from a customer recently who wanted to configure all vCenter alarms to send a notification email. This instantly made me decide that PowerCLI was the best way to go rather than wasting a lot of valuable time in the vSphere client configuring the email notification alarms.</p>
<h2>PowerCLI Automation Script:</h2>
<p>I&#8217;ve created a quick and dirty script to do the job that I wanted to share with you. It&#8217;s probably not the fastest or the best optimized script, but it got the job done.</p>
<pre class="brush: powershell; title: ; notranslate">
Get-AlarmDefinition | %{
   $_ | Set-AlarmDefinition -ActionRepeatMinutes (60 * 24);
   $_ | New-AlarmAction -Email -To &quot;vcenteralerts@bwinparty.com&quot; | %{
      $_ | New-AlarmActionTrigger -StartStatus &quot;Green&quot; -EndStatus &quot;Yellow&quot; -Repeat
      $_ | Get-AlarmActionTrigger | ?{$_.repeat -eq $false} | Remove-AlarmActionTrigger -Confirm:$false
      $_ | New-AlarmActionTrigger -StartStatus &quot;Yellow&quot; -EndStatus &quot;Red&quot; -Repeat
   }
}
</pre>
<p><strong>Line 1:</strong> The script first retrieves all the alarms. You can easily adapt the script to update only a specific alarms by changing this line to include the name of the alarm you want to update like:</p>
<pre class="brush: powershell; title: ; notranslate">Get-AlarmDefinition &quot;Datastore usage on disk&quot;</pre>
<p>or even all datastore alarms with:</p>
<pre class="brush: powershell; title: ; notranslate">Get-AlarmDefinition &quot;Datastore*&quot;</pre>
<p><strong>Line 2:</strong> The script then configures the alarm action repeat frequency to repeat the action every 24 hours. The value must be specified in minutes and the default value is to repeat every 5 minutes.</p>
<p><strong>Line 3:</strong> On this line a new send notification email action is created to send an email to the email address vcenteralarms@customer.corp.</p>
<p><strong>Line 4:</strong> This creates an alarm action trigger when the status changes from &#8220;Green&#8221; to &#8220;Yellow&#8221; or from &#8220;Normal&#8221; to &#8220;Warning&#8221;.</p>
<p><strong>Line 5:</strong> During the creation of the send notification email alarm action, a default alarm action trigger is created. Because there&#8217;s currently no Set-AlarmActionTrigger cmdlet available, I decided that it&#8217;s easier to remove the default trigger rather than trying to change it from &#8220;Once&#8221; to &#8220;Repeat&#8221; by falling back to using the SDK methods. I warned you that it was quick and dirty <img src='http://www.van-lieshout.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><strong>Line 6:</strong> finally this line creates an alarm action trigger when the status changes from &#8220;Yellow&#8221; to &#8220;Red&#8221; or from &#8220;Warning&#8221; to &#8220;Alert&#8221;.</p>
<p>Have Fun!</p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2010/12/a-new-powercli-release-and-a-new-year%e2%80%99s-feature/' rel='bookmark' title='Permanent Link: A new PowerCLI release and a New Year’s feature'>A new PowerCLI release and a New Year’s feature</a></li>
<li><a href='http://www.van-lieshout.com/2010/05/powercli-disableenable-ha-and-drs/' rel='bookmark' title='Permanent Link: PowerCLI: Disable/Enable HA and DRS'>PowerCLI: Disable/Enable HA and DRS</a></li>
<li><a href='http://www.van-lieshout.com/2011/06/drs-rules/' rel='bookmark' title='Permanent Link: Managing VMware DRS rules using PowerCLI'>Managing VMware DRS rules using PowerCLI</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/a0DRdqXbWCPjDdPmxsL0SfnZlOI/0/da"><img src="http://feedads.g.doubleclick.net/~a/a0DRdqXbWCPjDdPmxsL0SfnZlOI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/a0DRdqXbWCPjDdPmxsL0SfnZlOI/1/da"><img src="http://feedads.g.doubleclick.net/~a/a0DRdqXbWCPjDdPmxsL0SfnZlOI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/17xzWdMOiSw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2012/01/powercli-automation-create-vcenter-notification-email-alarm-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2012/01/powercli-automation-create-vcenter-notification-email-alarm-action/</feedburner:origLink></item>
		<item>
		<title>Top Bloggers Voting Time Again</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/RViqpgQQ3iM/</link>
		<comments>http://www.van-lieshout.com/2012/01/top-bloggers-voting-time-again/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 15:29:46 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1857</guid>
		<description><![CDATA[
			
				
			
		
Eric Siebert has opened up another top VMware &#38; virtualization blogs poll over at vSphere-land.com.  Please take a moment and cast your vote  for your favourite 10 bloggers.  It&#8217;ll take only a couple of minutes of your time and you can win a copy of the Train Signal’s new vSphere 5 and View 5 video training courses.
So head on [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2010/09/voting-time-top-25-vmware-virtualization-blogs/' rel='bookmark' title='Permanent Link: Voting Time! &#8211; Top 25 VMware Virtualization Blogs'>Voting Time! &#8211; Top 25 VMware Virtualization Blogs</a></li>
<li><a href='http://www.van-lieshout.com/2010/09/ranked-27-in-eric-siebert%e2%80%99s-top-vmware-bloggers-survey/' rel='bookmark' title='Permanent Link: Ranked #27 in Eric Siebert’s Top VMware bloggers survey'>Ranked #27 in Eric Siebert’s Top VMware bloggers survey</a></li>
<li><a href='http://www.van-lieshout.com/2010/01/voted-29-top-blogger-on-vsphere-land-com/' rel='bookmark' title='Permanent Link: Voted #29 top blogger on vSphere-land.com'>Voted #29 top blogger on vSphere-land.com</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2012%2F01%2Ftop-bloggers-voting-time-again%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2012%2F01%2Ftop-bloggers-voting-time-again%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Eric Siebert has opened up another top VMware &amp; virtualization blogs poll over at <a title="vSphere-land voting" href="http://vsphere-land.com/news/voting-now-open-for-the-top-25-vmware-virtualization-blogs.html" target="_blank">vSphere-land.com</a>.  Please take a moment and cast your vote  for your favourite 10 bloggers.  It&#8217;ll take only a couple of minutes of your time and you can win a copy of the Train Signal’s new <a href="http://www.trainsignal.com/VMware-vSphere-5-Training.aspx" target="_blank">vSphere 5</a> and <a href="http://www.trainsignal.com/VMware-View-5-Essentials-Training.aspx" target="_blank">View 5</a> video training courses.</p>
<p>So head on over to <a href="http://vote.vsphere-land.com/" target="_blank">http://vote.vsphere-land.com</a> to cast your vote and reward the best bloggers for their hard work and dedication by letting them know that you appreciate them. They deserve it!</p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2010/09/voting-time-top-25-vmware-virtualization-blogs/' rel='bookmark' title='Permanent Link: Voting Time! &#8211; Top 25 VMware Virtualization Blogs'>Voting Time! &#8211; Top 25 VMware Virtualization Blogs</a></li>
<li><a href='http://www.van-lieshout.com/2010/09/ranked-27-in-eric-siebert%e2%80%99s-top-vmware-bloggers-survey/' rel='bookmark' title='Permanent Link: Ranked #27 in Eric Siebert’s Top VMware bloggers survey'>Ranked #27 in Eric Siebert’s Top VMware bloggers survey</a></li>
<li><a href='http://www.van-lieshout.com/2010/01/voted-29-top-blogger-on-vsphere-land-com/' rel='bookmark' title='Permanent Link: Voted #29 top blogger on vSphere-land.com'>Voted #29 top blogger on vSphere-land.com</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/jqcItBFd3UgpDgCnfZIoi8EqLHk/0/da"><img src="http://feedads.g.doubleclick.net/~a/jqcItBFd3UgpDgCnfZIoi8EqLHk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/jqcItBFd3UgpDgCnfZIoi8EqLHk/1/da"><img src="http://feedads.g.doubleclick.net/~a/jqcItBFd3UgpDgCnfZIoi8EqLHk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/RViqpgQQ3iM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2012/01/top-bloggers-voting-time-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2012/01/top-bloggers-voting-time-again/</feedburner:origLink></item>
		<item>
		<title>PHD Virtual Backup and Replication 5.3</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/ySLftRPJ4ks/</link>
		<comments>http://www.van-lieshout.com/2011/11/phd-virtual-backup-and-replication-5-3/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 19:10:51 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1844</guid>
		<description><![CDATA[
			
				
			
		
PHD Virtual Backup and Replication 5.3, earlier demonstrated at VMworld 2011 by PHD Virtual, is coming soon. According to PHD Virtual it will be offering even faster backup and restore of virtual machines and new technologies that offer more flexibility for disaster recovery of your virtual environment.
NEW FEATURES

New Job Processing Engine with I/O optimizations
Up to [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2010/03/how-sure-is-your-backup/' rel='bookmark' title='Permanent Link: How sure is your backup?'>How sure is your backup?</a></li>
<li><a href='http://www.van-lieshout.com/2010/03/moving-your-virtual-center-sql-database-beware/' rel='bookmark' title='Permanent Link: Moving your Virtual Center SQL database &#8211; Beware!'>Moving your Virtual Center SQL database &#8211; Beware!</a></li>
<li><a href='http://www.van-lieshout.com/2011/03/vsphere-client-for-ipad/' rel='bookmark' title='Permanent Link: vSphere Client for iPad &#8211; Another step forward in mobile administration'>vSphere Client for iPad &#8211; Another step forward in mobile administration</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F11%2Fphd-virtual-backup-and-replication-5-3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F11%2Fphd-virtual-backup-and-replication-5-3%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>PHD Virtual Backup and Replication 5.3, earlier demonstrated at VMworld 2011 by PHD Virtual, is coming soon. According to PHD Virtual it will be offering even faster backup and restore of virtual machines and new technologies that offer more flexibility for disaster recovery of your virtual environment.</p>
<h4>NEW FEATURES</h4>
<ul>
<li>New Job Processing Engine with I/O optimizations</li>
<li>Up to 8 Concurrent Data Streams per VBA (Enterprise Edition)</li>
<li>Virtual Machine Replication</li>
<li>Virtual Machine Test Mode</li>
<li>Mass Restore Virtual Machines</li>
<li>Open Export of VM’s from Backup Storage to standard OVF</li>
<li>Tape Friendly Backup Support</li>
</ul>
<p>For more information have a look at the <a title="PHD Virtual Backup and Replication 5.3 Datasheet" href="http://www.phdvirtual.com/pdf/datasheets/PHDVBR53-Datasheet.pdf" target="_blank">PHD5.3 Datasheet</a> or watch the recently released demo video below.<br />
<object style="height: 292px; width: 480px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/Eft4kJnTADQ?version=3&amp;feature=player_detailpage" /><param name="allowfullscreen" value="true" /><embed style="height: 292px; width: 480px;" type="application/x-shockwave-flash" width="100" height="100" src="http://www.youtube.com/v/Eft4kJnTADQ?version=3&amp;feature=player_detailpage" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2010/03/how-sure-is-your-backup/' rel='bookmark' title='Permanent Link: How sure is your backup?'>How sure is your backup?</a></li>
<li><a href='http://www.van-lieshout.com/2010/03/moving-your-virtual-center-sql-database-beware/' rel='bookmark' title='Permanent Link: Moving your Virtual Center SQL database &#8211; Beware!'>Moving your Virtual Center SQL database &#8211; Beware!</a></li>
<li><a href='http://www.van-lieshout.com/2011/03/vsphere-client-for-ipad/' rel='bookmark' title='Permanent Link: vSphere Client for iPad &#8211; Another step forward in mobile administration'>vSphere Client for iPad &#8211; Another step forward in mobile administration</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/1zSwV5o0datv06huM6SnzoDPhg8/0/da"><img src="http://feedads.g.doubleclick.net/~a/1zSwV5o0datv06huM6SnzoDPhg8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1zSwV5o0datv06huM6SnzoDPhg8/1/da"><img src="http://feedads.g.doubleclick.net/~a/1zSwV5o0datv06huM6SnzoDPhg8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/ySLftRPJ4ks" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/11/phd-virtual-backup-and-replication-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/11/phd-virtual-backup-and-replication-5-3/</feedburner:origLink></item>
		<item>
		<title>Masking LUN paths using PowerCLI</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/sn8ircqWI_0/</link>
		<comments>http://www.van-lieshout.com/2011/07/esxcli-masking-lun-paths-powercli/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 11:45:11 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[ESX]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Storage]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1815</guid>
		<description><![CDATA[
			
				
			
		
I got a question on my previous post about the Get-EsxCli cmdlet, ESXCLI the PowerCLI way, from Alasdair Carnie who was having trouble using the Get-EsxCli cmdlet to mask luns at the ESXi host level. In this post I&#8217;ll show you how to accomplish LUN masking at the ESXi host level.
Note 1:
Before you read any further, please [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/esxcli-powercli/' rel='bookmark' title='Permanent Link: ESXCLI the PowerCLI way'>ESXCLI the PowerCLI way</a></li>
<li><a href='http://www.van-lieshout.com/2011/01/esxi-tech-support-mode/' rel='bookmark' title='Permanent Link: ESXi Tech Support Mode'>ESXi Tech Support Mode</a></li>
<li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F07%2Fesxcli-masking-lun-paths-powercli%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F07%2Fesxcli-masking-lun-paths-powercli%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I got a question on my previous post about the Get-EsxCli cmdlet, <a title="ESXCLI whe PowerCLI way" href="http://www.van-lieshout.com/2011/01/esxcli-powercli/" target="_self">ESXCLI the PowerCLI way</a>, from Alasdair Carnie who was having trouble using the Get-EsxCli cmdlet to mask luns at the ESXi host level. In this post I&#8217;ll show you how to accomplish LUN masking at the ESXi host level.</p>
<p><strong>Note 1:<br />
</strong>Before you read any further, please notice that the Get-EsxCli cmdlet is experimental. Also notice that in order to retrieve an esxcli instance you have to be connected directly to an ESX host.</p>
<p><strong>Note 2:<br />
</strong>When using the esxcli methods in PowerCLI, remember that you pay close attention to the definition of the specific method. You <strong>always</strong> have to provide a value for <strong>every</strong> parameter. If you don’t need to provide a value for a specific parameter, you have to specify the $null value.</p>
<p>Now that we are aware of these requirements, let’s create an additional claimrule to mask a LUN at the ESXi host level. Before we create a new claimrule, we’re going to have a look at the running claimrules on the ESXi host first.</p>
<h2><span id="more-1815"></span>Viewing the currently running claimrules</h2>
<p>First we create an esxcli instance from PowerCLI</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli = Get-EsxCli</pre>
<p>To view the currently running claimrules, we need to call the list() method in the corestorage.claimrule branch.</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.claimrule.list()</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_1.png"><img class="alignnone size-full wp-image-1817" title="maskpath_1" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_1.png" alt="" width="519" height="280" /></a></p>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_1.png"></a>Note that I piped the output to ft, which is an alias of the Format-Table cmdlet, to forcibly show the output in table format. As you can see, there are two types of claimrule entries present. The “runtime” class is the rules currently running in the Pluggable Storage Architecture (PSA). The “file” class is a reference to the rules present in the /etc/vmware/esx.conf file. You’ll notice later on that after you create a claimrule it’s initially only listed in the “file” class until you explicitly load the new ruleset.</p>
<h2>Adding a new claimrule</h2>
<p>When you want to mask a LUN or path, you have to specify a claimrule for the MASK_PATH plugin. To view the available plugins run:</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.plugin.list()</pre>
<p>To add a new claimrule we need to call the add() method of the corestorage.claimrule branch. First let’s have a close look at the method’s definition.</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.claimrule | gm</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_2.png"><img class="alignnone size-full wp-image-1818" title="maskpath_2" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_2.png" alt="" width="519" height="280" /></a></p>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_2.png"></a>As you notice, the definition is hard to read, as it doesn’t fit in the screen. For this purpose you can better view the output in list format (Format-List or fl). To avoid showing a large list of all methods and properties, we narrow our output to include only the add() method using a where filter.</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.claimrule | gm | where {$_.name -eq &quot;add&quot;} | fl</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_3.png"><img class="alignnone size-full wp-image-1819" title="maskpath_3" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_3.png" alt="" width="519" height="280" /></a></p>
<p>As you can notice there are a lot of parameters available for creating claimrules. Remember that you have to specify <strong>ALL</strong> of them. Parameters that aren’t required need to be specified as $null</p>
<p>For a detailed command description, see <a title="VMware vSphere Online Library" href="http://pubs.vmware.com/vsp40/wwhelp/wwhimpl/js/html/wwhelp.htm#href=fc_san_config/r_esxcli_corestorage_options.html" target="_blank">esxcli corestorage Command-Line Options</a>.</p>
<p>For this purpose I’ve presented an iSCSI LUN to my ESXi host which is located at vmhba33:C0:T0:L0.  To list the devices that are available to the ESXi host run the command:</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.device.list()</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_4.png"><img class="alignnone size-full wp-image-1820" title="maskpath_4" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_4.png" alt="" width="519" height="280" /></a></p>
<p>As you can see, the last device listed is my iSCSI LUN.</p>
<p>To add a claimrule for the MASK_PATH plugin for this iSCSI device we issue:</p>
<pre class="brush: powershell; title: ; notranslate">
$esxcli.corestorage.claimrule.add(&quot;vmhba33&quot;,$null,0,$null,$null,
    $null,$null,0,$null,&quot;MASK_PATH&quot;,102,0,$null,&quot;location&quot;,$null)
</pre>
<p><strong>Note 1:</strong><strong><br />
</strong><strong> </strong>The previous command masks only one path to the iSCSI device (vmhba33:C0:T0:L0). If there are more paths available, you’ll need to add additional rules for each path to completely hide the device.</p>
<p><strong>Note 2:<br />
</strong>I specified 102 for the rule number as this is the next available number.</p>
<p>We can now verify the creation of our claimrule by listing the available claimrules again.</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.claimrule.list()</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_5.png"><img class="alignnone size-full wp-image-1821" title="maskpath_5" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_5.png" alt="" width="519" height="280" /></a></p>
<p>Notice that the new claimrule is only available in the “file” class, but is not actively running. We need to first load the new ruleset into our system.</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.claimrule.load()
$esxcli.corestorage.claimrule.list()</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_6.png"><img class="alignnone size-full wp-image-1822" title="maskpath_6" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_6.png" alt="" width="519" height="281" /></a></p>
<p>As you can see; our new claiming rule is now available in the “runtime” class and hence active.</p>
<h2>Re-Claiming the LUN</h2>
<p>We’re not quite there yet, as we need to perform one last step. Our iSCSI LUN is still claimed by the NMP plugin. We can verify this by listing the storage devices using:</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.device.list()</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_7.png"><img class="alignnone size-full wp-image-1823" title="maskpath_7" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_7.png" alt="" width="519" height="280" /></a></p>
<p>Notice that the iSCSI LUN is still present. We need to unclaim the iSCSI LUN from the NMP plugin and run the claiming rules so that the iSCSI LUN can be claimed by our new masking rule.</p>
<pre class="brush: powershell; title: ; notranslate">
$esxcli.corestorage.claiming.unclaim(&quot;vmhba33&quot;,0,$null,$null,
    $null,0,$null, $null,$null,0,&quot;location&quot;,$null)
$esxcli.corestorage.claimrule.run()
</pre>
<p>Now we verify by listing the devices again.</p>
<pre class="brush: powershell; title: ; notranslate">$esxcli.corestorage.device.list()</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_8.png"><img class="alignnone size-full wp-image-1824" title="maskpath_8" src="http://www.van-lieshout.com/wp-content/uploads/2011/07/maskpath_8.png" alt="" width="519" height="281" /></a></p>
<p>As you can see, the iSCSI LUN is now masked and not available anymore.</p>
<h2>Summarizing</h2>
<p>Let’s summarize all the steps to add a claimrule for path vmhba33:C0:T0:L0</p>
<pre class="brush: powershell; title: ; notranslate">
$esxcli.corestorage.claimrule.add(&quot;vmhba33&quot;,$null,0,$null,$null,
    $null,$null,0,$null,&quot;MASK_PATH&quot;,102,0,$null,&quot;location&quot;,$null)
$esxcli.corestorage.claimrule.load()
$esxcli.corestorage.claiming.unclaim(&quot;vmhba33&quot;,0,$null,$null,
    $null,0,$null,$null,$null,0,&quot;location&quot;,$null)
$esxcli.corestorage.claimrule.run()
</pre>
<p>As you can see, it’s quite a hassle to mask a path or LUN at the ESXi host level and because of that is can be very error-prone. Also during a re-install this configuration is lost and you have to re-mask everything and can possibly run into issues. Masking LUNs at the ESXi host level has very specific use cases and should only be used as a last resort, when masking at the storage level isn’t a possible solution. That’s why I recommend against masking paths from the ESXi host level.</p>
<p><strong>Best Practice<br />
</strong>Perform LUN masking at the storage level</p>
<h2>Unmasking the path</h2>
<p>If you want to unmask the path, so that is will be available to the ESXi host again, use this code:</p>
<pre class="brush: powershell; title: ; notranslate">
$esxcli.corestorage.claimrule.delete($null,102)
$esxcli.corestorage.claimrule.load()
$esxcli.corestorage.claiming.unclaim(&quot;vmhba33&quot;,0,$null,$null,
    $null,0,$null,$null,$null,0,&quot;location&quot;,$null)
$esxcli.corestorage.claimrule.run()
</pre>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/esxcli-powercli/' rel='bookmark' title='Permanent Link: ESXCLI the PowerCLI way'>ESXCLI the PowerCLI way</a></li>
<li><a href='http://www.van-lieshout.com/2011/01/esxi-tech-support-mode/' rel='bookmark' title='Permanent Link: ESXi Tech Support Mode'>ESXi Tech Support Mode</a></li>
<li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/9Czl_2yfcwmIX-B6CI3cEheUYUM/0/da"><img src="http://feedads.g.doubleclick.net/~a/9Czl_2yfcwmIX-B6CI3cEheUYUM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9Czl_2yfcwmIX-B6CI3cEheUYUM/1/da"><img src="http://feedads.g.doubleclick.net/~a/9Czl_2yfcwmIX-B6CI3cEheUYUM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/sn8ircqWI_0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/07/esxcli-masking-lun-paths-powercli/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/07/esxcli-masking-lun-paths-powercli/</feedburner:origLink></item>
		<item>
		<title>Managing VMware DRS rules using PowerCLI</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/CxKxMdGAzfU/</link>
		<comments>http://www.van-lieshout.com/2011/06/drs-rules/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 12:15:25 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[DRS]]></category>
		<category><![CDATA[PowerCLI]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1757</guid>
		<description><![CDATA[
			
				
			
		
One of the core features of VMware vSphere is the Distributed Resource Scheduler (DRS). VMware DRS is vSphere’s workload load balancer and relies on VMware vMotion technology to live-migrate workloads from one ESX host to another.
You can constrain the VMware DRS decisions by defining DRS Rules. As of vSphere 4.1 there are 2 type of [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
<li><a href='http://www.van-lieshout.com/2010/05/powercli-disableenable-ha-and-drs/' rel='bookmark' title='Permanent Link: PowerCLI: Disable/Enable HA and DRS'>PowerCLI: Disable/Enable HA and DRS</a></li>
<li><a href='http://www.van-lieshout.com/2011/01/esxcli-powercli/' rel='bookmark' title='Permanent Link: ESXCLI the PowerCLI way'>ESXCLI the PowerCLI way</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F06%2Fdrs-rules%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F06%2Fdrs-rules%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the core features of VMware vSphere is the Distributed Resource Scheduler (DRS). VMware DRS is vSphere’s workload load balancer and relies on VMware vMotion technology to live-migrate workloads from one ESX host to another.</p>
<p>You can constrain the VMware DRS decisions by defining DRS Rules. As of vSphere 4.1 there are 2 type of DRS rules:</p>
<ul>
<li>VM-to-VM rules</li>
<li>VM-to-Host rules (new in vSphere 4.1)</li>
</ul>
<h2><em>VM-to-VM rules</em></h2>
<p>Until vSphere 4.1 you could only create VM-to-VM rules. This type of rule specifies the affinity between virtual machines (VMs). You can define both affinity- and anti-affinity rules.</p>
<h3>Affinity rules</h3>
<p>Affinity rules keep workloads together on the same ESX host. This is beneficial if for instance an application server needs fast access to its database that resides on another VM. Keeping both VMs together on the same host boosts performance as network traffic between the VMs won’t leave the ESX host. Note that if both servers are in different VLANs or subnets this benefit could be undone, as network traffic might need to be routed externally.</p>
<h3>Anti-affinity rules</h3>
<p>Anti-affinity rules separate workloads on different ESX hosts. This is beneficial if you have services running on multiple servers for redundancy, like domain controllers or Network Load Balancing (NLB) clusters. In these situations you want to make sure that the VMs are distributed over different ESX hosts. If one ESX host fails, the service would still be available through other VM(s) residing on other ESX hosts.</p>
<h3><span id="more-1757"></span>Using PowerCLI</h3>
<p>You can manage the DRS rules through the properties of the Cluster (Remember that DRS is a vCenter cluster feature) using the vSphere Client, but you can also use PowerCLI. Using PowerCLI, DRS rules are retrieved with the Get-DrsRule cmdlet:</p>
<pre>[vSphere PowerCLI] C:\Scripts&gt; Get-DrsRule –Cluster CL01
Name            Enabled KeepTogether VMIDs
----            ------- ------------ -----
App01_Affinity  True    True         {VirtualMachine-vm-35672, VirtualM...
DC_Separate     True    False        {VirtualMachine-vm-35697, VirtualM...
</pre>
<p>Notice that only the VM IDs are returned for the configured VMs and not their names. You probably want the associated VM’s names to appear in your report instead of the VM IDs.</p>
<p>This can be accomplished using the New-VIProperty cmdlet:</p>
<pre class="brush: powershell; title: ; notranslate">
New-VIProperty -Name VMs -ObjectType DrsVMAffinityRule -Value {
param($rule)
foreach($vm in $rule.VMIDs) {(Get-VM -Id $vm).Name}
}
</pre>
<pre>[vSphere PowerCLI] C:\Scripts&gt; Get-DrsRule –Cluster CL01 | Select Name,
&gt;&gt; Enabled, KeepTogether, VMs
Name           Enabled KeepTogether VMs
----           ------- ------------ ---
App01_Affinity    True         True {Arnim1, Arnim2}
DC_Separate       True        False {Arnim3, Arnim4}
</pre>
<p>You can now easily export your DRS rules for the sake of documentation or backup using the Export-CSV cmdlet.</p>
<pre>[vSphere PowerCLI] C:\Scripts&gt; Get-DrsRule –Cluster CL01 | Select Name,
&gt;&gt; Enabled, KeepTogether, VMs | Export-Csv CL01_Rules.csv
</pre>
<p>If you want to add a new rule, you can use the New-DRSRule cmdlet. To create a new DRS rule you need to specify the following mandatory parameters:</p>
<ul>
<li>Name: The name for the new DRS rule.</li>
<li>Cluster: The cluster for which the new DRS rule applies.</li>
<li>KeepTogether: Specify $true to create a new affinity rule, or $false to create a new anti-affinity rule.</li>
<li>VM: The VMs to include in the new DRS rule</li>
</ul>
<p>Let’s create a new anti-affinity rule for our proxy NLB cluster:</p>
<pre>[vSphere PowerCLI] C:\Scripts&gt; New-DrsRule –Name ProxyNLB_separate `
&gt;&gt; -Cluster CL01 –KeepTogether:$false –VM Proxy01,Proxy02
</pre>
<p>To verify the new rule, simply retrieve the DRS rules using the Get-DrsRule cmdlet again:</p>
<pre>[vSphere PowerCLI] C:\Scripts&gt; Get-DrsRule –Cluster CL01 | Select Name,
&gt;&gt; Enabled, KeepTogether, VMs
Name                       Enabled        KeepTogether VMs
----                       -------        ------------ ---
App01_Affinity                True                True {Arnim1, Arnim2}
DC_Seperate                   True               False {Arnim3, Arnim4}
ProxyNLB_Separate             True               False {Proxy01, Proxy02}
</pre>
<p>Removing a DRS rule is accomplished using the Delete-DrsRule cmdlet. This cmdlet requires you to specify a DrsVMAffinityRule object. This means that you can’t specify the rule by name, but you need to retrieve the rule object using the Get-DrsRule cmdlet first. Let’s remove the App01_Affinity rule:</p>
<pre>[vSphere PowerCLI] C:\Scripts&gt; Get-DrsRule –Cluster CL01 `
&gt;&gt; –Name App01_Affinity | Remove-DrsRule –Confirm:$false</pre>
<h2><em>VM-to-Host rules</em></h2>
<p>vSphere 4.1 extended DRS functionality with DRS groups and the VM-to-Host rule type. With this type of rule you can specify the affinity between a group of VMs and a group of ESX hosts (inside a cluster). There are four rule types:</p>
<ul>
<li>Should</li>
<li>Should not</li>
<li>Must</li>
<li>Must not</li>
</ul>
<h3>Mandatory rules (&#8220;Must&#8221; rules)</h3>
<p>Mandatory rules are used in specific cases, such as licensing requirements. As an example let’s have a look to Oracle’s licensing requirements. Oracle states that in a virtual environment every socket in every ESX host in the cluster must be licensed, because the Oracle VM can potentially run on every host. Using a mandatory rule you can limit the Oracle VM to only run on the licensed ESX hosts.</p>
<h3>Preferential rules (&#8220;Should&#8221; rules)</h3>
<p>Preferential rules can be used in availability scenario’s, where a group of VMs is split across blade enclosures or racks. In the event of a loss of an enclosure or rack, the availability of the service or application is not jeopardized and HA is allowed to &#8220;violate&#8221; the preferential rule and restart the failed VMs on the surviving enclosures or racks. VMware HA isn&#8217;t aware of preferential rules because they aren&#8217;t communicated to HA by DRS.</p>
<p>Creating the new VM-to-Host type of rules is only available through the vSphere client and not using the standard VMware PowerCLI cmdlets at this time. But do not fear. I’ve created a couple of functions to allow you to automate this. The creation of a VM-to-Host rule is a three-step process:</p>
<ol>
<li>Define a group of VMs (VMGroup)</li>
<li>Define a group of ESX hosts (HostGroup)</li>
<li>Create the VM-to-Host rule</li>
</ol>
<h3>Creating VMGroups</h3>
<p>A VMGroup can be created using the New-DrsVmGroup function from Listing 1. To create a new VMGroup that contains virtual machines VM001 and VM002:</p>
<pre>Get-VM VM001,VM002 | New-DrsVmGroup -Name "VmGroup01" -Cluster CL01</pre>
<p><strong>Listing 1</strong></p>
<pre class="brush: powershell; title: ; notranslate">
Function New-DrsVmGroup {
&lt;#
.SYNOPSIS
  Creates a new DRS VM group
.DESCRIPTION
  This function creates a new DRS VM group in the DRS Group Manager
.NOTES
  Author: Arnim van Lieshout
.PARAMETER VM
  The VMs to add to the group. Supports objects from the pipeline.
.PARAMETER Cluster
  The cluster to create the new group on.
.PARAMETER Name
  The name for the new group.
.EXAMPLE
  PS&gt; Get-VM VM001,VM002 | New-DrsVmGroup -Name &quot;VmGroup01&quot; -Cluster CL01
.EXAMPLE
  PS&gt; New-DrsVmGroup -VM VM001,VM002 -Name &quot;VmGroup01&quot; -Cluster (Get-CLuster CL01)
#&gt;

	Param(
		[parameter(valuefrompipeline = $true, mandatory = $true,
		HelpMessage = &quot;Enter a vm entity&quot;)]
			[PSObject]$VM,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a cluster entity&quot;)]
			[PSObject]$Cluster,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a name for the group&quot;)]
			[String]$Name)

	begin {
	    switch ($Cluster.gettype().name) {
      		&quot;String&quot; {$cluster = Get-Cluster $cluster | Get-View}
      		&quot;ClusterImpl&quot; {$cluster = $cluster | Get-View}
      		&quot;Cluster&quot; {}
      		default {throw &quot;No valid type for parameter -Cluster specified&quot;}
		}
		$spec = New-Object VMware.Vim.ClusterConfigSpecEx
		$group = New-Object VMware.Vim.ClusterGroupSpec
		$group.operation = &quot;add&quot;
		$group.Info = New-Object VMware.Vim.ClusterVmGroup
		$group.Info.Name = $Name
	}

	Process {
		switch ($VM.gettype().name) {
      		&quot;String&quot; {Get-VM -Name $VM | %{$group.Info.VM += $_.Extensiondata.MoRef}}
      		&quot;VirtualMachineImpl&quot; {$group.Info.VM += $VM.Extensiondata.MoRef}
      		&quot;VirtualMachine&quot; {$group.Info.VM += $VM.MoRef}
      		default {throw &quot;No valid type for parameter -VM specified&quot;}
	    }
	}

	End {
		if ($group.Info.VM) {
			$spec.GroupSpec += $group
			$cluster.ReconfigureComputeResource_Task($spec,$true)
		}
		else {
      		throw &quot;No valid VMs specified&quot;
		}
	}
}
</pre>
<h3>Creating HostGroups</h3>
<p>Now that a VMGroup is created, you need to define a HostGroup. This can be accomplished using the New-DrsHostGroup function from Listing 2. To create a new HostGroup that contains ESX hosts ESX001 and ESX002:</p>
<pre>Get-VMHost ESX001,ESX002 | New-DrsHostGroup -Name "HostGroup01" `
    -Cluster CL01</pre>
<p><strong>Listing 2</strong></p>
<pre class="brush: powershell; title: ; notranslate">
Function New-DrsHostGroup {
&lt;#
.SYNOPSIS
  Creates a new DRS host group
.DESCRIPTION
  This function creates a new DRS host group in the DRS Group Manager
.NOTES
  Author: Arnim van Lieshout
.PARAMETER VMHost
  The hosts to add to the group. Supports objects from the pipeline.
.PARAMETER Cluster
  The cluster to create the new group on.
.PARAMETER Name
  The name for the new group.
.EXAMPLE
  PS&gt; Get-VMHost ESX001,ESX002 | New-DrsHostGroup -Name &quot;HostGroup01&quot; -Cluster CL01
.EXAMPLE
  PS&gt; New-DrsHostGroup -Host ESX001,ESX002 -Name &quot;HostGroup01&quot; -Cluster (Get-CLuster CL01)
#&gt;

	Param(
		[parameter(valuefrompipeline = $true, mandatory = $true,
		HelpMessage = &quot;Enter a host entity&quot;)]
			[PSObject]$VMHost,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a cluster entity&quot;)]
			[PSObject]$Cluster,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a name for the group&quot;)]
			[String]$Name)

	begin {
	    switch ($Cluster.gettype().name) {
      		&quot;String&quot; {$cluster = Get-Cluster $cluster | Get-View}
      		&quot;ClusterImpl&quot; {$cluster = $cluster | Get-View}
      		&quot;Cluster&quot; {}
      		default {throw &quot;No valid type for parameter -Cluster specified&quot;}
		}
		$spec = New-Object VMware.Vim.ClusterConfigSpecEx
		$group = New-Object VMware.Vim.ClusterGroupSpec
		$group.operation = &quot;add&quot;
		$group.Info = New-Object VMware.Vim.ClusterHostGroup
		$group.Info.Name = $Name
	}

	Process {
		switch ($VMHost.gettype().name) {
      		&quot;String&quot; {Get-VMHost -Name $VMHost | %{$group.Info.Host += $_.Extensiondata.MoRef}}
      		&quot;VMHostImpl&quot; {$group.Info.Host += $VMHost.Extensiondata.MoRef}
      		&quot;HostSystem&quot; {$group.Info.Host += $VMHost.MoRef}
      		default {throw &quot;No valid type for parameter -VMHost specified&quot;}
	    }
	}

	End {
		if ($group.Info.Host) {
			$spec.GroupSpec += $group
			$cluster.ReconfigureComputeResource_Task($spec,$true)
		}
		else {
      		throw &quot;No valid hosts specified&quot;
		}
	}
}
</pre>
<h3>Creating VM-to-Host rules</h3>
<p>Now that both VM- and HostGroup are created, you can start creating a VM-to-Host DRS rule. As mentioned before, there are rules to keep VMs on the specified set of Host or to keep them off these hosts. Using the New-DrsVmToHostRule function from Listing 3 you can create your VM-to-Host rule. By default the function will create an affine type of rule, unless you specify the opposite using the -AntiAffine switch parameter. The rule type is a preferential rule by default (&#8220;Should&#8221; rule) unless you specify the -Mandatoy parameter, which creates a mandatory rule (&#8220;Must&#8221; rule).</p>
<p>To create a mandatory anti-affinity rule (&#8220;Must Not&#8221; rule) between VMGroup01 and HostGroup01 to prevent the VMs from VMGroup01 to be executed on the ESX hosts in HostGroup01:</p>
<pre>New-DrsVMToHostRule -VMGroup "VMGroup01" -HostGroup "HostGroup01" –Name `
    "VMToHostRule01" -Cluster CL01 -AntiAffine –Mandatory</pre>
<p><strong>Listing 3</strong></p>
<pre class="brush: powershell; title: ; notranslate">
Function New-DRSVMToHostRule{
&lt;#
.SYNOPSIS
  Creates a new DRS VM to host rule
.DESCRIPTION
  This function creates a new DRS vm to host rule
.NOTES
  Author: Arnim van Lieshout
.PARAMETER VMGroup
  The VMGroup name to include in the rule.
.PARAMETER HostGroup
  The VMHostGroup name to include in the rule.
.PARAMETER Cluster
  The cluster to create the new rule on.
.PARAMETER Name
  The name for the new rule.
.PARAMETER AntiAffine
  Switch to make the rule an AntiAffine rule. Default rule type is Affine.
.PARAMETER Mandatory
  Switch to make the rule mandatory (Must run rule). Default rule is not mandatory (Should run rule)
.EXAMPLE
  PS&gt; New-DrsVMToHostRule -VMGroup &quot;VMGroup01&quot; -HostGroup &quot;HostGroup01&quot; -Name &quot;VMToHostRule01&quot; -Cluster CL01 -AntiAffine -Mandatory
#&gt;

	Param(
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a VM DRS group name&quot;)]
			[String]$VMGroup,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a host DRS group name&quot;)]
			[String]$HostGroup,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a cluster entity&quot;)]
			[PSObject]$Cluster,
		[parameter(mandatory = $true,
		HelpMessage = &quot;Enter a name for the group&quot;)]
			[String]$Name,
			[Switch]$AntiAffine,
			[Switch]$Mandatory)

    switch ($Cluster.gettype().name) {
   		&quot;String&quot; {$cluster = Get-Cluster $cluster | Get-View}
   		&quot;ClusterImpl&quot; {$cluster = $cluster | Get-View}
   		&quot;Cluster&quot; {}
   		default {throw &quot;No valid type for parameter -Cluster specified&quot;}
	}

	$spec = New-Object VMware.Vim.ClusterConfigSpecEx
	$rule = New-Object VMware.Vim.ClusterRuleSpec
	$rule.operation = &quot;add&quot;
	$rule.info = New-Object VMware.Vim.ClusterVmHostRuleInfo
	$rule.info.enabled = $true
	$rule.info.name = $Name
	$rule.info.mandatory = $Mandatory
	$rule.info.vmGroupName = $VMGroup
	if ($AntiAffine) {
		$rule.info.antiAffineHostGroupName = $HostGroup
	}
	else {
		$rule.info.affineHostGroupName = $HostGroup
	}
	$spec.RulesSpec += $rule
	$cluster.ReconfigureComputeResource_Task($spec,$true)
}
</pre>
<p>As a general rule of recommendation: Use DRS rules, both VM-to-VM and VM-to-Host, sparingly, as every rule you create limits the choices DRS has to move VMs across ESX hosts. Also remember that mandatory rules stay in effect even when DRS is disabled! To disable mandatory rules, you need to disable them manually.</p>
<p>If you want to learn more about VMware DRS, I highly recommend reading the <a title="VMware vSphere 4.1 HA &amp; DRS technical deepdive" href="http://www.amazon.com/gp/product/1456301446/ref=as_li_tf_tl?ie=UTF8&amp;tag=arnivanlies-20&amp;link_code=as3&amp;camp=211189&amp;creative=373489&amp;creativeASIN=1456301446" target="_blank">VMware vSphere 4.1 HA and DRS technical deepdive</a>.</p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
<li><a href='http://www.van-lieshout.com/2010/05/powercli-disableenable-ha-and-drs/' rel='bookmark' title='Permanent Link: PowerCLI: Disable/Enable HA and DRS'>PowerCLI: Disable/Enable HA and DRS</a></li>
<li><a href='http://www.van-lieshout.com/2011/01/esxcli-powercli/' rel='bookmark' title='Permanent Link: ESXCLI the PowerCLI way'>ESXCLI the PowerCLI way</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/K9cQLacQ8Jwto8RhCTMXUHRCiCM/0/da"><img src="http://feedads.g.doubleclick.net/~a/K9cQLacQ8Jwto8RhCTMXUHRCiCM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/K9cQLacQ8Jwto8RhCTMXUHRCiCM/1/da"><img src="http://feedads.g.doubleclick.net/~a/K9cQLacQ8Jwto8RhCTMXUHRCiCM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/CxKxMdGAzfU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/06/drs-rules/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/06/drs-rules/</feedburner:origLink></item>
		<item>
		<title>Living the dream</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/fIWcKK818UE/</link>
		<comments>http://www.van-lieshout.com/2011/05/living-the-dream/#comments</comments>
		<pubDate>Mon, 16 May 2011 11:52:51 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1749</guid>
		<description><![CDATA[
			
				
			
		
Who would’ve thought that 2011 would become such a great year for me? Earlier this year a dream came true with the release of our PowerCLI book on March 28th. Now, only 2 months after, another dream is about to happen. I think I can honestly say that I’m living my dream right now.
Well, it’s [...]


No related posts.]]></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%2Fwww.van-lieshout.com%2F2011%2F05%2Fliving-the-dream%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F05%2Fliving-the-dream%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Who would’ve thought that 2011 would become such a great year for me? Earlier this year a dream came true with the release of our <a title="PowerCLIBook" href="http://www.powerclibook.com" target="_blank">PowerCLI book</a> on March 28th. Now, only 2 months after, another dream is about to happen. I think I can honestly say that I’m living my dream right now.</p>
<p>Well, it’s official.<br />
I will be joining VMware as a Senior Consultant starting June 6th.</p>
<p>After almost 13 years, I’m leaving my current employer <a title="KEMBIT" href="http://www.kembit.nl" target="_blank">KEMBIT</a>. During that period KEMBIT has always felt like family to me, so deciding to leave them was not that easy. On the other hand, working for VMware was something I could only dream about and I simply couldn’t refuse the offer. <img src='http://www.van-lieshout.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I want to thank KEMBIT for the opportunity to let me grow my VMware knowledge and for their support and understanding. Thanks guys, it was a blast.</p>


<p>No related posts.</p>
<p><a href="http://feedads.g.doubleclick.net/~a/zHG-cx0e70OdijCZxQY_7-Js8q8/0/da"><img src="http://feedads.g.doubleclick.net/~a/zHG-cx0e70OdijCZxQY_7-Js8q8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zHG-cx0e70OdijCZxQY_7-Js8q8/1/da"><img src="http://feedads.g.doubleclick.net/~a/zHG-cx0e70OdijCZxQY_7-Js8q8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/fIWcKK818UE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/05/living-the-dream/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/05/living-the-dream/</feedburner:origLink></item>
		<item>
		<title>The PowerCLI Book Raffle – Behind the scenes</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/89xJWIpTLLk/</link>
		<comments>http://www.van-lieshout.com/2011/04/the-powercli-book-raffle-%e2%80%93-behind-the-scenes/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 12:52:36 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1727</guid>
		<description><![CDATA[
			
				
			
		
Now that our PowerCLI Book Raffle has ended and the lucky winner is published, I want to give you a full disclosure of the drawing process. Because our PowerCLI Book is about PowerCLI, what other tool than PowerShell could we use to perform the drawing process?
Twitter Fun
So first we need to retrieve all the twitter messages that [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/powercli-book-update/' rel='bookmark' title='Permanent Link: PowerCLI Book Update'>PowerCLI Book Update</a></li>
<li><a href='http://www.van-lieshout.com/2010/01/powershell-powercli-linkage/' rel='bookmark' title='Permanent Link: PowerShell / PowerCLI linkage'>PowerShell / PowerCLI linkage</a></li>
<li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F04%2Fthe-powercli-book-raffle-%25e2%2580%2593-behind-the-scenes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F04%2Fthe-powercli-book-raffle-%25e2%2580%2593-behind-the-scenes%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Now that our <a title="PowerCLI Book Raffle" href="http://www.powerclibook.com/powercli-book-raffle/" target="_blank">PowerCLI Book Raffle</a> has ended and <a title="PowerCLI Book Raffle Winner" href="http://www.powerclibook.com/powercli-book-raffle-winner-announcement/" target="_blank">the lucky winner</a> is published, I want to give you a full disclosure of the drawing process. Because our <a title="Order PowerCLI Book Here" href="http://www.amazon.com/dp/0470890797?tag=arnivanlies-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=0470890797&amp;adid=1Z7SWZ0X65ZV4PYEQ2ER&amp;" target="_blank">PowerCLI Book</a> is about PowerCLI, what other tool than PowerShell could we use to perform the drawing process?</p>
<h3>Twitter Fun</h3>
<p>So first we need to retrieve all the twitter messages that people re-tweeted on Twitter. In order to do that we need to call the HTTP based <a title="Twitter Search" href="http://search.twitter.com" target="_blank">Twitter search API</a>. For more information on how to use the Twitter search API have a look at <a title="Twitter Search API" href="http://search.twitter.com/api/" target="_blank">http://search.twitter.com/api/</a> This page shows us that the Twitter search API supports the Atom format through the Atom service URL &#8220;http://search.twitter.com/search.atom?q=&lt;query&gt;&#8221;. It also shows us the supported URL parameters. The most important parameters are:</p>
<ul>
<li>rpp: the number of tweets to return per page, up to a max of 100</li>
<li>page: the page number to return, up to a max of roughly 1500 results (based on rpp * page</li>
</ul>
<p>In order to perform a simple search, we only need to fill in the query parameter. We are interested in all messages that contain both “powerclibook” and “magictweet”. In order to search for tweets that contain both words, we need to concatenate them with the plus (+) sign, like http://search.twitter.com/search.atom?q=powerclibook+magictweet. To see the results you could simply paste that URL into your browser.<br />
<a href="http://www.van-lieshout.com/wp-content/uploads/2011/04/fig1-twittersearch.png"><img class="size-medium wp-image-1728 alignnone" title="Twitter Search" src="http://www.van-lieshout.com/wp-content/uploads/2011/04/fig1-twittersearch-300x143.png" alt="" width="300" height="143" /></a>   </p>
<p><span id="more-1727"></span>To capture the result in PowerShell, we need to create a WebClient object using:</p>
<pre class="brush: powershell; title: ; notranslate">
$WebClient = New-Object System.Net.WebClient
</pre>
<p>To download the Twitter search results we use the DownloadString method like:</p>
<pre class="brush: powershell; title: ; notranslate">
$WebClient.DownloadString(&quot;http://search.twitter.com/search.atom?q=powerclibook+magictweet&quot;)
</pre>
<p>The downloaded Atom result is actually an XML formatted string. In order to process the result as actual XML instead of a string we need to convert the string into the XML type. This is also referred to as type casting.</p>
<pre class="brush: powershell; title: ; notranslate">
$searchResult = [xml]$WebClient.DownloadString(&quot;http://search.twitter.com/search.atom?q=powerclibook+magictweet&quot;)
</pre>
<p>So far so good. We now have our Twitter search results. We can retrieve the individual tweets through the <strong>.feed.entry</strong> property, however there are only 15 tweets present by default in our search results. This is where the additional <strong>-rpp</strong> parameter kicks in. Using this parameter we can override the default of 15 tweets per page to a maximum of 100 tweets per page. The returned number of tweets per page can also be found in the <strong>.feed.itemsPerPage</strong> property.  Let’s try the search again using the <strong>-rpp</strong> parameter:</p>
<pre class="brush: powershell; title: ; notranslate">
$searchResult = [xml]$WebClient.DownloadString(&quot;http://search.twitter.com/search.atom?q=powerclibook+magictweet&amp;rpp=100&quot;)
</pre>
<p>[vSphere PowerCLI] C:\scripts&gt; $searchResult.feed.itemsPerPage</p>
<p>100What if we want to retrieve more than 100 results? This is where we get to use the <strong>-page</strong> parameter. With the <strong>-page</strong> parameter you define the page number that gets returned. The number of pages is determined by the total number of search results (maximum is 1500) divided by the results per page (rpp). Fortunately we don’t have to determine how many pages are available to us, because Atom provides <a title="Atom Link Model" href="http://www.xml.com/lpt/a/1434" target="_blank">a link model</a> that allows us to easily browse pages. The Atom links are stored under the <strong>.feed.link</strong> property.</p>
<pre>[vSphere PowerCLI] C:\scripts&gt; $searchResult.feed.link

type                       href                       rel
----                       ----                       ---
text/html                  http://search.twitter.c... alternate
application/atom+xml       http://search.twitter.c... self
application/opensearchd... http://search.twitter.c... search
application/atom+xml       http://search.twitter.c... refresh</pre>
<p>In order to retrieve the next page we only have to retrieve the appropriate URL from the <strong>.feed.link</strong> property and use that URL with the <strong>.DownloadString</strong> method of our WebClient.</p>
<pre class="brush: powershell; title: ; notranslate">
$url = ($searchResult.feed.link | ?{$_.rel -eq &quot;next&quot;}).href  
$nextResult = [xml]$WebClient.DownloadString($url)  
</pre>
<p>Now we only need to put all the pieces together to retrieve all re-tweeted magic tweets.  </p>
<pre class="brush: powershell; title: ; notranslate">
$WebClient = New-Object System.Net.WebClient  
$url = &quot;http://search.twitter.com/search.atom?q=powerclibook+magictweet&amp;rpp=100&quot;  
$tweets=@()  
while ($url) {  
    $searchResult = [xml]$WebClient.DownloadString($url)  
    $tweets += $searchResult.feed.entry  
    $url = ($searchResult.feed.link | ?{$_.rel -eq &quot;next&quot;}).href  
}  
</pre>
<p>To make things easier and reusable, I’ve created a Search-Twitter function using this code.  </p>
<pre class="brush: powershell; title: ; notranslate">
function Search-Twitter {
&lt;#
.SYNOPSIS
  Finds tweets on Twitter
.DESCRIPTION
  This function finds tweets on Twitter that match the query provided by the -query parameter.
  A WebClient needs to be defined in the $Global:WebClient variable. If no WebClient is found, a default WebClient will be created.
.NOTES
  Author:  Arnim van Lieshout
.PARAMETER Query
  The search query
.PARAMETER All
  An optional switch parameter to retrieve the maximum number of tweets. By default only the first page will be returned
.EXAMPLE
  PS&gt; Search-Twitter -Query &quot;PowerCLI&quot;
.EXAMPLE
  PS&gt; Search-Twitter -Query &quot;PowerCLI&quot; -All
#&gt;

	param(
		[Parameter(Mandatory = $true, Position = 0, HelpMessage = &quot;Enter the search query&quot;)]
			[String]$Query,
			[Switch]$All
	)

	$url = &quot;http://search.twitter.com/search.atom?rpp=100&amp;q=$Query&quot;

	if (!$WebClient) {$Global:WebClient = New-Object System.Net.WebClient}

	$messages = @()
	if ($All) {
		while ($url) {
			$searchResult = [xml]$WebClient.DownloadString($url)
			$messages += $searchResult.feed.entry
			$url = ($searchResult.feed.link | ?{$_.rel -eq &quot;next&quot;}).href
		}
	}
	else {
		$searchResult = [xml]$WebClient.DownloadString($url)
		$messages += $searchResult.feed.entry
	}

	$messages
}
</pre>
<h3>Collecting The Magic Tweets</h3>
<p>Using our newly crafted Search-Twitter function we collect the re-tweeted magic tweets and save some information about the tweet and the user in a custom object. Because the maximum number of returned search results is 1500 and search results aren’t kept forever on Twitter (the Twitter history only goes back to approximately four days), we run our script on a daily basis and export the results to an XML file.  </p>
<pre class="brush: powershell; title: ; notranslate">
#COLLECT TWEETS
$WebClient = New-Object System.Net.WebClient  

$tweets = @()
foreach ($item in (Search-Twitter &quot;powerclibook+magictweet&quot; -All)) {
	$obj = &quot;&quot; | Select user_id, user, user_name, user_uri, profile_image_url, published, text, source

	$obj.user = $item.author.uri.split('/')[-1]
	$userInfo = [xml]$WebClient.DownloadString(&quot;http://api.twitter.com/1/users/show.xml?screen_name=$($obj.user)&quot;)
	$obj.user_id = $userInfo.user.id
	$obj.user_name = $userInfo.user.name
	$obj.user_uri = $item.author.uri
	$obj.profile_image_url = ($item.link | ?{$_.rel -eq &quot;image&quot;}).href
	$obj.published = [DateTime]$item.published
	$obj.text = $item.title
	$obj.source = $item.source

	$tweets += $obj
}

$tweets | Export-Clixml C:\Scripts\PowerCLIBookRaffle_$(get-date -Format yyy-MM-dd).xml
</pre>
<p>Notice that we also used the Twitter API to retrieve user information. We decided to use the Twitter user id as the user’s ticket number for our raffle. This way we can ensure that only one ticket per user is issued, regardless of the number of times the user re-tweeted the magic tweet.</p>
<h3>The Draw</h3>
<p>After collecting all the re-tweeted magic tweets, it’s time to draw one lucky winner. First we need to read all saved search results. Because we collected the tweets on a daily basis and some users re-tweeted the magic tweet multiple times, there are duplicates and we need to de-duplicate the collected tweets first before we can actually draw the winner. To keep the raffle fair, we also decided to exclude the authors from entering the draw.  </p>
<p>In order the retrieve our saved search results, we can simply import then using: </p>
<pre class="brush: powershell; title: ; notranslate">
#Import tweets
$tweets = @()
$tweets = Get-ChildItem &quot;C:\Scripts\PowerCLIBookRaffle*&quot; | Import-Clixml
</pre>
<p>Because of the duplicates, we need to de-duplicate the $tweets array. This can easily be achieved using the Sort-Object cmdlet. </p>
<pre class="brush: powershell; title: ; notranslate">
#Dedup tweets
$tweets = $tweets | Sort-Object -Property user_id -Unique
</pre>
<p>Next task is removing the authors.   </p>
<pre class="brush: powershell; title: ; notranslate">
#Remove authors
$authors = @(&quot;alanrenouf&quot;,&quot;LucD22&quot;,&quot;avlieshout&quot;,&quot;jonathanmedd&quot;,&quot;glnsize&quot;)
$tweets = $tweets | ?{$authors -notcontains $_.user}
</pre>
<p>To simulate the process of mixing the tickets in the jar, we switched 2 random objects in the array multiple times. Using the code below we switched tickets 10.000 times:  </p>
<pre class="brush: powershell; title: ; notranslate">
#Mix tickets
1..10000 | %{
	$random1 = Get-Random -Minimum 0 -Maximum $tweets.count
	$random2 = Get-Random -Minimum 0 -Maximum $tweets.count
	$tempObject = $tweets[$random1]
	$tweets[$random1] = $tweets[$random2]
	$tweets[$random2] = $tempObject
}
</pre>
<p>The last task to do is to actually draw the lucky winner:     </p>
<pre class="brush: powershell; title: ; notranslate">
#Draw the lucky winner
$winner = $tweets | Get-Random
$winner
</pre>
<p><a href="http://www.van-lieshout.com/wp-content/uploads/2011/04/fig2-thedraw.png"><img class="alignnone size-medium wp-image-1742" title="The Draw" src="http://www.van-lieshout.com/wp-content/uploads/2011/04/fig2-thedraw-300x180.png" alt="" width="300" height="180" /></a></p>
<h3>References</h3>
<p>Twitter Search API Documentation &#8211; <a href="http://search.twitter.com/api/">http://search.twitter.com/api/</a><br />
Twitter Developer Documentation &#8211; <a href="http://dev.twitter.com/doc">http://dev.twitter.com/doc</a><br />
The Atom Link model &#8211; <a href="http://www.xml.com/lpt/a/1434">http://www.xml.com/lpt/a/1434</a></p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/powercli-book-update/' rel='bookmark' title='Permanent Link: PowerCLI Book Update'>PowerCLI Book Update</a></li>
<li><a href='http://www.van-lieshout.com/2010/01/powershell-powercli-linkage/' rel='bookmark' title='Permanent Link: PowerShell / PowerCLI linkage'>PowerShell / PowerCLI linkage</a></li>
<li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/hbtJOUIP8HeDYT_0nnjcV7hDVOc/0/da"><img src="http://feedads.g.doubleclick.net/~a/hbtJOUIP8HeDYT_0nnjcV7hDVOc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/hbtJOUIP8HeDYT_0nnjcV7hDVOc/1/da"><img src="http://feedads.g.doubleclick.net/~a/hbtJOUIP8HeDYT_0nnjcV7hDVOc/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/89xJWIpTLLk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/04/the-powercli-book-raffle-%e2%80%93-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/04/the-powercli-book-raffle-%e2%80%93-behind-the-scenes/</feedburner:origLink></item>
		<item>
		<title>VMware vSphere PowerCLI Reference: Automating vSphere Administration</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/BHfrMx9xxu8/</link>
		<comments>http://www.van-lieshout.com/2011/03/vmware-vsphere-powercli-reference-automating-vsphere-administration/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 13:45:57 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1712</guid>
		<description><![CDATA[
			
				
			
		
It has been quite a journey, but it has finally arrived. Today our book: &#8220;VMware vSphere PowerCLI Reference: Automating vSphere Administration&#8221; will be released by Sybex. The journey started about a year ago when Alan Renouf and Luc Dekens decided to write a PowerCLI book that should have a practical approach to vSphere administration. Later [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2009/06/setting-custom-attributes-with-vmware-powercli/' rel='bookmark' title='Permanent Link: Setting custom attributes with VMware PowerCLI'>Setting custom attributes with VMware PowerCLI</a></li>
<li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
<li><a href='http://www.van-lieshout.com/2011/01/powercli-book-update/' rel='bookmark' title='Permanent Link: PowerCLI Book Update'>PowerCLI Book Update</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F03%2Fvmware-vsphere-powercli-reference-automating-vsphere-administration%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F03%2Fvmware-vsphere-powercli-reference-automating-vsphere-administration%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignleft size-full wp-image-1713" title="PowerCLI Book Cover" src="http://www.van-lieshout.com/wp-content/uploads/2011/03/bookcover_small.jpg" alt="" width="100" height="125" />It has been quite a journey, but it has finally arrived. Today our book: <em>&#8220;VMware vSphere PowerCLI Reference: Automating vSphere Administration&#8221;</em> will be released by Sybex. The journey started about a year ago when <a title="Virtually everthing is poshable" href="http://www.virtu-al.net/" target="_blank">Alan Renouf</a> and <a title="LucD notes" href="http://www.lucd.info/" target="_blank">Luc Dekens</a> decided to write a PowerCLI book that should have a practical approach to vSphere administration. Later that year they contacted 3 co-authors to help them out in order to keep meeting the deadlines. The PowerCLI book team was born and the book was to be written by &#8220;4 vExperts and a MVP&#8221;.</p>
<p>From this point I would like to personally thank Alan and Luc for the opportunity to realize a dream. I would also like to personally thank <a title="Mary Ellen Schutz, your Gentle Editor" href="http://www.gentleediting.net/" target="_blank">Mary Ellen Schutz</a>, Developmental Editor, for transforming my technical gibberish into readable and most importantly understandable language. Last but not least I would like to personally thank our Technical Editor, <a title="Vinternals" href="http://blog.vinternals.com/" target="_blank">Stuart Radnidge</a>. He left no script unturned and served as the gatekeeper, ensuring that any code you find in the book will run the first time, every time. You might think that&#8217;s all there is to it, but then you&#8217;re wrong. I&#8217;ve never written a book before and I was impressed by the number of people that were involved behind the scenes in this book thing. On the Sybex team there were numerous people involved including but not limited to: Editorial Manager, Acquisition Editor, Production Editor, Copyeditor, Indexer, Proofreader and Compositor. Without each of their contributions, this book would have never made it to the presses.</p>
<h3><span id="more-1712"></span>Target Audience</h3>
<p>The book is, of course, primarily targeted at administrators of vSphere environments who want to automate tasks. But the subjects that we discuss in the book cover so many aspects of the management of a VMware vSphere environment that everyone who comes into contact with a VMware vSphere environment will be able to pick up something useful.</p>
<p>In our day-to-day contact with PowerCLI users, we noticed that most of them start with what we like to call the reporting phase. Thanks to the natural look and feel of PowerShell and PowerCLI, it is quite easy for beginners to produce impressive reports about their vSphere environment. That&#8217;s why we included several chapters on different types of reporting. The somewhat more advanced user will go into the configuration phase. That is the moment when you start changing settings on your virtual guests and in the vSphere servers. There are an extensive number of chapters for this phase in the book.</p>
<p>The ultimate phase you can achieve through the use of PowerCLI is the process automation phase. As an administrator, you are now going to automate complex processes in your vSphere environment. This process can range from automating the deployment of vSphere servers all the way to automating the switch to a disaster recovery center. Again, the book offers several chapters for this phase.</p>
<h3>What&#8217;s inside</h3>
<p>This book shows you how you can use PowerCLI to automate your administrator tasks—not an alphabetical listing of the 250+ PowerCLI cmdlets—but a practical guide with example scripts that you can use immediately in your environment. The chapters are organized in such a way that each of them reflects a specific type of task. You probably already have done most of these tasks more than once. Now, we will show you how to automate them. In other words, you script them once and run them multiple times.</p>
<p>The book consists of 5 parts:</p>
<p><strong>Part I: Install, Configure, and Manage the vSphere Environment<br />
</strong>Chapter 1 through Chapter 4 show you how to automate the installation and configuration of your VMware vSphere environment. They include the vCenter server, the ESX and ESXi servers, storage, and networking as well as some advanced vSphere features like host profiles and dvSwitches.</p>
<p><strong>Part II: Managing the Virtual Machine Life Cycle</strong><br />
Chapter 5 through Chapter 9 tackle all the automation aspects of guests—from creating a virtual machine over linked clones and svMotion all the way to vApps. We will show you how to mass-deploy a number of guests and how to manipulate snapshots.</p>
<p><strong>Part III: Securing Your vSphere Environment<br />
</strong>In Chapter 10 through Chapter 13, we discuss the security aspects of your VMware vSphere environment. First, we show you how to handle backups and restores. Then, we continue with the automation of your disaster recovery. Patching and hardening of your environment conclude this part.</p>
<p><strong>Part IV: Monitoring and Reporting<br />
</strong>Chapter 14 through Chapter 17 show how you can automate all the reporting aspects of your VMware vSphere environment. These chapters discuss how to report on the physical hardware, virtual hardware, and the configuration parameters; how to gather statistical data for performance and capacity planning reports; how to create an audit trail; and how to monitor the environment.</p>
<p><strong>Part V: Scripting Tools and Features<br />
</strong>In Chapter 18 through Chapter 23, we expand on the automation scripts themselves. We&#8217;ll show you how you can schedule your scripts, how to use the methods and properties from the SDK in your scripts, and how to use Onyx to help you with the SDK methods and properties. You&#8217;ll learn how to run your scripts in graphical environments like PowerGUI, and how to provide your own graphical interface for your scripts. We also introduce PowerWF Studio, a novel way to work with PowerShell and the PowerCLI snap-in.</p>
<p>A complete table of contents can be found on <a title="PowerCLI Book Website" href="http://www.powerclibook.com/powercli-book-table-of-contents/" target="_blank">www.powerclibook.com</a> or even better, <a title="Have a look inside" href="http://www.amazon.com/dp/0470890797?tag=arnivanlies-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=0470890797&amp;adid=1Z7SWZ0X65ZV4PYEQ2ER&amp;" target="_blank">have a look inside the book on amazon</a>.</p>
<p>As you might already know, we created a dedicated website at <a title="PowerCLI Book website" href="http://www.powerclibook.com" target="_blank">www.powerclibook.com</a>, to provide you with any additional information regarding our book. If you have any book related questions, please visit our <a title="PowerCLI book forum" href="http://powerclibook.com/Forum/" target="_blank">PowerCLI book forum</a> and let us know.</p>
<p>We hope that you will enjoy reading this book as much as we did writing it.</p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2009/06/setting-custom-attributes-with-vmware-powercli/' rel='bookmark' title='Permanent Link: Setting custom attributes with VMware PowerCLI'>Setting custom attributes with VMware PowerCLI</a></li>
<li><a href='http://www.van-lieshout.com/2011/02/rescan-esxi/' rel='bookmark' title='Permanent Link: Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified'>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</a></li>
<li><a href='http://www.van-lieshout.com/2011/01/powercli-book-update/' rel='bookmark' title='Permanent Link: PowerCLI Book Update'>PowerCLI Book Update</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/w0RpL6iIf-D8eiMFBaNGyKsShwk/0/da"><img src="http://feedads.g.doubleclick.net/~a/w0RpL6iIf-D8eiMFBaNGyKsShwk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/w0RpL6iIf-D8eiMFBaNGyKsShwk/1/da"><img src="http://feedads.g.doubleclick.net/~a/w0RpL6iIf-D8eiMFBaNGyKsShwk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/BHfrMx9xxu8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/03/vmware-vsphere-powercli-reference-automating-vsphere-administration/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/03/vmware-vsphere-powercli-reference-automating-vsphere-administration/</feedburner:origLink></item>
		<item>
		<title>vSphere Client for iPad – Another step forward in mobile administration</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/UqWU5uAjOyg/</link>
		<comments>http://www.van-lieshout.com/2011/03/vsphere-client-for-ipad/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 09:30:48 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[vCenter]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1686</guid>
		<description><![CDATA[
			
				
			
		
Today VMware announced the release of the vSphere Client for iPad. The first great thing is that you can download the vSphere Client for iPad from Apple&#8217;s iTunes Store for FREE! The second great thing is that it looks really awesome and the interface is very intuitive.
VMware is taking mobility very seriously as this is [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/brocade-network-advisor-vmware-vcenter-plug-in/' rel='bookmark' title='Permanent Link: Brocade Network Advisor Management Plug-in for VMware vCenter'>Brocade Network Advisor Management Plug-in for VMware vCenter</a></li>
<li><a href='http://www.van-lieshout.com/2010/01/critical-2009-last-minute-esx3-5-patches/' rel='bookmark' title='Permanent Link: Critical 2009 last-minute ESX3.5 patches'>Critical 2009 last-minute ESX3.5 patches</a></li>
<li><a href='http://www.van-lieshout.com/2009/11/powercli-4-0-update-1-another-leap-forward/' rel='bookmark' title='Permanent Link: PowerCLI 4.0 Update 1- Another leap forward'>PowerCLI 4.0 Update 1- Another leap forward</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F03%2Fvsphere-client-for-ipad%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F03%2Fvsphere-client-for-ipad%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignleft" src="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie1.png" alt="" width="193" height="150" />Today VMware announced the release of the vSphere Client for iPad. The first great thing is that you can download the vSphere Client for iPad from Apple&#8217;s iTunes Store for FREE! The second great thing is that it looks really awesome and the interface is very intuitive.</p>
<p>VMware is taking mobility very seriously as this is their second application specifically for the iPad. Recently VMware released the VMware View Client for iPad. The vSphere Client for iPad isn&#8217;t meant to be a fully functional equivalent for the existing Windows client, but allows you to do the most common tasks, according to VMware. With the current release, the functionality offered by the vSphere Client for iPad is:</p>
<ul>
<li>Search for vSphere hosts and virtual machines</li>
<li>Monitor the performance of vSphere hosts and virtual machines</li>
<li>Manage virtual machines with the ability to start, stop and suspend</li>
<li>View and restore virtual machines&#8217; snapshots</li>
<li>Reboot vSphere hosts or put them into maintenance mode</li>
<li>Diagnose vSphere hosts and virtual machines using built-in ping and traceroute tools</li>
</ul>
<p>The ability to manage your vSphere environment with a mobile device isn&#8217;t new, as VMware already provides the vCenter Mobile Acces (vCMA) virtual appliance. If you&#8217;re familiar with this vCMA, you might recognize the vSphere Client for iPad&#8217;s functionality. In fact it&#8217;s built on top of this vCMA. The vCMA is required in order for the vSphere Client for iPad to function and can be obtained from VMware free of charge at <a href="http://labs.vmware.com/flings/vcma">http://labs.vmware.com/flings/vcma</a> The latest version of the vCMA has now SSL configured by default, to make sure your connection is secure. Because you connect to the vCMA virtual appliance using standard SSL, you can easily use the vSphere Client for iPad to connect to the vCMA through a firewall to manage your vSphere environment.</p>
<h2><span id="more-1686"></span>Setting up your environment</h2>
<h3>Part 1: Configure vCMA Virtual Appliance</h3>
<ol>
<li>Extract the zip file to a temporary directory, for example c:\temp. The files contained in the zip file include:
<ul>
<li>vCenterMobileAccess-1.x.y.z.ovf</li>
<li>system.vmdk</li>
</ul>
</li>
<li>Launch the vSphere client and log into your vSphere Host or vCenter Server.</li>
<li>In the inventory view, select the menu File -&gt; Deploy OVF Template…</li>
<li>Select &#8220;Deploy from a file or URL&#8221;, browse to the OVF file, and follow the wizard next steps.</li>
<li>In the &#8220;End User License Agreement&#8221; page, read the license agreement completely and click on the &#8220;Accept all license agreements&#8221; and continue the steps.</li>
<li>In the &#8220;Name and Location&#8221; page, provide the name for your Virtual Machine.</li>
<li>Once the wizard completes, a virtual machine will be created. Select the virtual machine and power it on.</li>
<li>You can then add the appliance to your DNS server. This step has to be done manually; you can use only the IP address if you prefer but you can also enter a host name for the appliance.</li>
</ol>
<p>VMware also released a video to show you how to setup the vCMA.<br />
<iframe title="YouTube video player" width="520" height="323" src="http://www.youtube.com/embed/msjXKWFdgcM?rel=0" frameborder="0" allowfullscreen></iframe></p>
<p><strong>NOTE:</strong> After the vCMA virtual appliance is deployed, you might notice that it is still at virtual hardware level 4. I guess that&#8217;s done for backwards compatibility. You can upgrade the vCMA virtual appliance to virtual hardware level 7, if you deployed it on vSphere.</p>
<p>With the vCMA in place, it&#8217;s time to get the vSphere Client for iPad set up.</p>
<h3>Part 2: Configure &amp; use the iPad app</h3>
<ol>
<li>Download the vSphere Client for iPad application from the iTunes Store.</li>
<li>Once the vCMA virtual appliance powers on, on the home screen of the iPad go to &#8220;Settings&#8221;, scroll down and tap on &#8220;vSphere Client&#8221;. Now enter the IP Address of the vCMA virtual appliance in the &#8220;Web Server&#8221; field (see image).<br />
<a href="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie2.png"><img src="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie2.png" alt="" width="216" height="288" /></a></li>
<li>Ensure your iPad has connectivity to the vCMA virtual appliance. This may entail configuring the iPad&#8217;s built-in VPN client. Consult Apple&#8217;s documentation on configuring the built-in VPN client.</li>
<li>Launch the vSphere Client for iPad application and enter the host, username and password for the vCenter Server or vSphere Host you wish to connect to<br />
<a href="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie3.png"><img src="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie3.png" alt="" width="290" height="385" /></a></li>
</ol>
<p>VMware also released a video to show you how to configure and use the vSphere Client for iPad<br />
<iframe title="YouTube video player" width="520" height="323" src="http://www.youtube.com/embed/6kRalVLzMvE?rel=0" frameborder="0" allowfullscreen></iframe></p>
<h2>First impression</h2>
<p>I haven&#8217;t had the opportunity to play with the vSphere Client for iPad myself. Watching the video provided by VMware, I was really impressed by the interface&#8217;s look and feel, but I also noticed a couple of shortcomings. When you&#8217;re logged into your environment, you are presented with a list of hosts that are available to you. What about your clusters? If you have a problem in a cluster, do you know which hosts belong to that cluster? Or just the other way around; when I have a problem with a host, I want to know which cluster (and client) is affected.</p>
<p>Monitoring your host is still limited to the core four: CPU usage%, Memory usage%, Disk KBps and Network KBps. The same is true for virtual machine monitoring. Additional information like memory ballooning or swapping is still missing, which is something you would definitely be interested in when performance is bad and I also haven&#8217;t seen an option to view alarms<br />
<a href="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie4.png"><img src="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie4.png" alt="" width="290" height="385" /></a></p>
<p>Another thing I noticed is the big Restore button on the virtual machine&#8217;s snapshots when viewing the virtual machine&#8217;s page. Shouldn&#8217;t this read &#8220;Go to&#8221; or &#8220;Revert to&#8221;? I don&#8217;t know wether I favour Go to, Revert or Restore, but I do favour consistency amongst the vSphere Clients. Again missing functionality is the ability to create or delete snapshots. Also the ability to migrate a virtual machine to another host is missing in this release.<br />
<a href="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie5.png"><img src="http://www.van-lieshout.com/wp-content/uploads/2011/03/031811_0206_vSphereClie5.png" alt="" width="290" height="385" /></a></p>
<h2>Conclusion</h2>
<p>The vSphere Client for iPad is definitely a 1.0 product, looking at functionality at this stage. But don&#8217;t get me wrong; I do like this product and I think it has a lot of potential. The look and feel of the interface is great and very intuitive, but more functionality needs to be added to be truly useful. But again I think it&#8217;s a great application and VMware has put a lot of effort in designing the interface specifically for mobile devices. I think you should definitely add it to your management gear. You never know when it might come in handy. That said, don&#8217;t underestimate the power of the vCMA. Some of the shortcomings I mentioned earlier are available directly from the vCMA. Just point the browser on your iPad to the IP address or DNS name of the vCMA. When logged into the vCMA, you&#8217;ll notice the ability to migrate virtual machines, see your clusters, view and run scheduled tasks, view alarms, view the virtual machine&#8217;s settings, create snapshots, and so forth. I think it&#8217;s very likely that this functionality will be added to the vSphere Client for iPad in one of  the future releases. VMware is planning to release updates on a IOS-frequency instead of vSphere-frequency, so my guess is that this app will evolve quickly and we don&#8217;t have to wait that long for fucntionality like vMotion to become available.</p>
<p>VMware has opened a community site for the vSphere Client for iPad. You can visit the iPad Client community at <a href="http://communities.vmware.com/community/vmtn/vsphere/ipadclient">http://communities.vmware.com/community/vmtn/vsphere/ipadclient</a>, where you can go for support and additional information.</p>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/brocade-network-advisor-vmware-vcenter-plug-in/' rel='bookmark' title='Permanent Link: Brocade Network Advisor Management Plug-in for VMware vCenter'>Brocade Network Advisor Management Plug-in for VMware vCenter</a></li>
<li><a href='http://www.van-lieshout.com/2010/01/critical-2009-last-minute-esx3-5-patches/' rel='bookmark' title='Permanent Link: Critical 2009 last-minute ESX3.5 patches'>Critical 2009 last-minute ESX3.5 patches</a></li>
<li><a href='http://www.van-lieshout.com/2009/11/powercli-4-0-update-1-another-leap-forward/' rel='bookmark' title='Permanent Link: PowerCLI 4.0 Update 1- Another leap forward'>PowerCLI 4.0 Update 1- Another leap forward</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/91Cdu58Pp3nY-VIJQqBu0UNWhIw/0/da"><img src="http://feedads.g.doubleclick.net/~a/91Cdu58Pp3nY-VIJQqBu0UNWhIw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/91Cdu58Pp3nY-VIJQqBu0UNWhIw/1/da"><img src="http://feedads.g.doubleclick.net/~a/91Cdu58Pp3nY-VIJQqBu0UNWhIw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/UqWU5uAjOyg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/03/vsphere-client-for-ipad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/03/vsphere-client-for-ipad/</feedburner:origLink></item>
		<item>
		<title>Rescan VMware vSphere Hypervisor (ESXi) using PowerCLI simplified</title>
		<link>http://feedproxy.google.com/~r/ArnimVanLieshout/~3/gQx17cR4BNo/</link>
		<comments>http://www.van-lieshout.com/2011/02/rescan-esxi/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 16:04:49 +0000</pubDate>
		<dc:creator>Arnim van Lieshout</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[ESX]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://www.van-lieshout.com/?p=1674</guid>
		<description><![CDATA[
			
				
			
		
While preparing some disaster recovery (DR) tests, I had to add and remove a couple of LUNS from several ESX hosts in different clusters. Doing so,  I had to rescan a lot of host bus adapters (HBA) several times. As I hate doing repetitive tasks in a graphical user interface (GUI), I always find myself [...]


Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/esxi-tech-support-mode/' rel='bookmark' title='Permanent Link: ESXi Tech Support Mode'>ESXi Tech Support Mode</a></li>
<li><a href='http://www.van-lieshout.com/2010/08/powercli-4-1-namespace-changes/' rel='bookmark' title='Permanent Link: PowerCLI 4.1 namespace changes'>PowerCLI 4.1 namespace changes</a></li>
<li><a href='http://www.van-lieshout.com/2010/07/collect-vmware-esx-host-pci-device-information/' rel='bookmark' title='Permanent Link: Collect VMware ESX Host PCI Device Information'>Collect VMware ESX Host PCI Device Information</a></li>
</ol>]]></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%2Fwww.van-lieshout.com%2F2011%2F02%2Frescan-esxi%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.van-lieshout.com%2F2011%2F02%2Frescan-esxi%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>While preparing some disaster recovery (DR) tests, I had to add and remove a couple of LUNS from several ESX hosts in different clusters. Doing so,  I had to rescan a lot of host bus adapters (HBA) several times. As I hate doing repetitive tasks in a graphical user interface (GUI), I always find myself quickly turning to the PowerCLI console. The PowerCLI command to rescan an ESX host is somewhere hidden in the <em>Get-VMHostStorage</em> cmdlet. This isn’t the most logical location and every time I have to perform a rescan operation I have to search for the correct command line syntax.</p>
<p>Today I decided to simplify that process and created a little PowerCLI function to simplify this task. The function I created is called <em><strong>Rescan-VMHost</strong></em> and accepts an ESX host name or host object as input parameter.</p>
<pre class="brush: powershell; title: ; notranslate">Rescan-VMHost ESX01</pre>
<p>The function also accepts host names or host objects from the pipeline. The optional <em>-IncludePeers</em> switch rescans all hosts in the given ESX host’s cluster additionally.</p>
<pre class="brush: powershell; title: ; notranslate">Get-VMHost ESX01 | Rescan-VMHost -IncludePeers</pre>
<p>As an extra bonus feature the function also accepts a cluster object as input parameter and will rescan all ESX hosts in the given cluster.</p>
<pre class="brush: powershell; title: ; notranslate">Get-Cluster CL01 | Rescan-VMHost</pre>
<p>Pretty cool huh?<br />
I&#8217;ve already used this little function a lot and hope you find a use case for it too.</p>
<p>One last thing. Although the title of this post might suggest that this function works on ESXi only, that is NOT the case. The function will work on both ESXi and ESX, but since VMware decided to go solely with ESXi and refers to it as the VMware vSphere Hypervisor, I decided to follow that path and hence the post&#8217;s title.</p>
<pre class="brush: powershell; title: ; notranslate">
function Rescan-VMHost {
&lt;#
.SYNOPSIS
  Performs a rescan operation on a specified ESX host or cluster
.DESCRIPTION
  This function rescans an ESX host or it's complete cluster when the -IncludePeers parameter is specified.
.NOTES
  Author: Arnim van Lieshout,
.PARAMETER Entity
  Specifies the hostname, host object or cluster object to perform the rescan operation on.
.PARAMETER IncludePeers
  Specifies that all the hosts in the host's cluster should be rescanned instead of only the host itself.
.EXAMPLE
  PS&gt; Rescan-VMHost ESX001
.EXAMPLE
  PS&gt; Get-VMHost ESX00* | Rescan-VMHost -IncludePeers
.EXAMPLE
  PS&gt; Get-Cluster CL01 | Rescan-VMHost
#&gt;

	Param (
		[parameter(valuefrompipeline = $true, mandatory = $true,
		HelpMessage = &quot;Enter an ESX(i) entity&quot;)]
			[PSObject]$Entity,
		[Switch]$IncludePeers)

	process {
		switch ($Entity.gettype().name) {
      		&quot;String&quot; {
				if ($IncludePeers) {Get-VMHost -Name $Entity | Rescan-VMHost -IncludePeers}
				else {Get-VMHost -Name $Entity | Rescan-VMHost}
			}
      		&quot;VMHostImpl&quot; {
				if ($IncludePeers) {
					foreach ($VMHost in Get-Cluster $Entity.Parent | Get-VMHost) {
						$VMHost | Get-VMHostStorage -RescanAllHba
					}
				}
				else {
					$Entity | Get-VMHostStorage -RescanAllHba
				}
			}
      		&quot;ClusterImpl&quot; {
				foreach ($VMHost in $Entity | Get-VMHost) {
					$VMHost | Get-VMHostStorage -RescanAllHba
				}
			}
      		default {throw &quot;No valid object type for parameter -VMHost specified&quot;}
	    }
	}
}
</pre>


<p>Related posts:<ol><li><a href='http://www.van-lieshout.com/2011/01/esxi-tech-support-mode/' rel='bookmark' title='Permanent Link: ESXi Tech Support Mode'>ESXi Tech Support Mode</a></li>
<li><a href='http://www.van-lieshout.com/2010/08/powercli-4-1-namespace-changes/' rel='bookmark' title='Permanent Link: PowerCLI 4.1 namespace changes'>PowerCLI 4.1 namespace changes</a></li>
<li><a href='http://www.van-lieshout.com/2010/07/collect-vmware-esx-host-pci-device-information/' rel='bookmark' title='Permanent Link: Collect VMware ESX Host PCI Device Information'>Collect VMware ESX Host PCI Device Information</a></li>
</ol></p>
<p><a href="http://feedads.g.doubleclick.net/~a/l6fEGQ87OI-LrG0brTHTmgDCUkQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/l6fEGQ87OI-LrG0brTHTmgDCUkQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/l6fEGQ87OI-LrG0brTHTmgDCUkQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/l6fEGQ87OI-LrG0brTHTmgDCUkQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/ArnimVanLieshout/~4/gQx17cR4BNo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.van-lieshout.com/2011/02/rescan-esxi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.van-lieshout.com/2011/02/rescan-esxi/</feedburner:origLink></item>
	</channel>
</rss>

