<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PeetersOnline &#187; PowerCLI</title>
	<atom:link href="http://www.peetersonline.nl/index.php/tag/powercli/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peetersonline.nl</link>
	<description>Using Powershell for (virtually) everything!</description>
	<lastBuildDate>Thu, 27 May 2010 08:01:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Set VMware Snapshot Location with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/set-vmware-snapshot-location-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/set-vmware-snapshot-location-with-powershell/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 13:09:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VI Toolkit 1.5]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[snapshots]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=411</guid>
		<description><![CDATA[Snapshots are m*th3rfcukers. If you&#8217;re not careful, they will mass-murder your vms. Yet they allow you to time-travel! You want to use them, but how to prevent a massacre? Here&#8217;s how: relocate the delta files. When you create a snapshot, the current state of the vm is preserved by leaving the disk files alone. All changes [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Snapshots are m*th3rfcukers. If you&#8217;re not careful, they will mass-murder your vms. Yet they allow you to time-travel! You want to use them, but how to prevent a massacre? Here&#8217;s how: relocate the delta files.</p>
<p>When you create a snapshot, the current state of the vm is preserved by leaving the disk files alone. All changes since the moment of creating the snapshot are written to delta files. The delta files are stored in the vm&#8217;s working directory. The working directory is &#8211; by default &#8211; the location where the vmx and other config files reside. If that datastore runs out of free space &#8211; especially if it also contains disk files &#8211; you&#8217;re in a bit of a kerfuffle. Vms not booting or being frozen as if they stared into Medusa&#8217;s reptoid eyes.</p>
<p>So you can do two things: reserve overhead in your datastores and stay afraid some overactive snapshot might destroy your environment, or set the working directory of your vms to some big-ass datastore you don&#8217;t use for anything else and let the snapshots enjoy themselves. If they fill up the datastore, they only kill all vms with snapshots, not the rest.</p>
<p>But how, you ask? You can edit the vmx files of you vms manually - which requires your vms to be powered down &#8211; and add the line: workingDir = &#8220;/vmfs/volumes/&lt;insanely long guid you need to somehow find&gt;/&#8221;</p>
<p>Or, you run my script and change the working location on the fly:</p>
<p><span id="more-411"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Description:</span>
<span style="color: #008000;"># Set's the Working Location for a VM. This location will hold the vswap and snapshot delta files.</span>
&nbsp;
<span style="color: #008000;"># Usage:</span>
<span style="color: #008000;"># First, connect to a virtual server server (Connect-VIServer)</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Set snapshot location for one vm (folder must already exist on datastore):</span>
<span style="color: #008000;"># Set-VMSnapshotLocation -vm VM001 -Location &quot;[BigAssDatastore] Snapshots&quot;</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># For all vms at once (no folder specified will put all in the root of the datastore):</span>
<span style="color: #008000;"># Get-VM | ForEach-Object {Set-VMSnapshotLocation -vm $_ -Location &quot;[BigAssDatastore]&quot;}</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Reset the location to the original location (with the vmx file):</span>
<span style="color: #008000;"># Set-VMSnapshotLocation -vm VM001 -Reset</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Set<span style="color: pink;">-</span>VMSnapshotLocation
	<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$vm</span><span style="color: pink;">,</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Location</span><span style="color: pink;">,</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">switch</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Reset</span><span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;">#Region Input Validation</span>
	<span style="color: #008000;"># Check vm parameter</span>
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$vm</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">Throw</span> <span style="color: #800000;">&quot;No VM specified.&quot;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #008000;"># Check Location parameter.</span>
	<span style="color: #008000;"># Can be empty when using Reset, can be &quot;[datastore]&quot; or can be &quot;[datastore] folder&quot; (folder must exist).</span>
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$Reset</span> <span style="color: #FF0000;">-and</span> <span style="color: #800080;">$Location</span> <span style="color: #FF0000;">-notmatch</span> <span style="color: #800000;">&quot;\[\S+\](\s\w+)?&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">Throw</span> <span style="color: #800000;">&quot;Invalid location specified. Syntax: [Datastore] Folder&quot;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #008000;"># Specifying Reset will set Location to empty, which causes the original location to be used (same location as vmx file).</span>
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Reset</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Location</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #008000;"># Make sure to get a vm object to work with.</span>
	<span style="color: #008000;"># This allows both using a vm name when targeting one vm (Set-VMSnapshotLocation -vm VM001 -Reset);</span>
	<span style="color: #008000;"># AND piping a collection of vm's (Get-VM | ForEach (Set-VMSnapshotLocation -vm $_ -Location &quot;[BigAssDatastore] Snapshots&quot; ).</span>
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vm</span>.GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Name <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;String&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$oVM</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VM <span style="color: #800080;">$vm</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">ElseIf</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vm</span>.GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Name <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;VirtualMachineImpl&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$oVM</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vm</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">Throw</span> <span style="color: #800000;">&quot;Parameter vm is of an invalid type.&quot;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #008000;">#EndRegion InputValidation</span>
&nbsp;
	<span style="color: #008000;">#Region Main</span>
	<span style="color: #008000;"># Get advanced properties of vm</span>
	<span style="color: #800080;">$vmView</span> <span style="color: pink;">=</span> <span style="color: #800080;">$oVM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View
	<span style="color: #008000;"># Create object containing new properties</span>
	<span style="color: #800080;">$vmConfigSpec</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineConfigSpec
	<span style="color: #800080;">$vmConfigSpec</span>.Files <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineFileInfo
	<span style="color: #800080;">$vmConfigSpec</span>.Files.SnapshotDirectory <span style="color: pink;">=</span> <span style="color: #800080;">$Location</span>
	<span style="color: #008000;"># Reconfigure VM using new properties</span>
	<span style="color: #800080;">$vmView</span>.ReconfigVM<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmConfigSpec</span><span style="color: #000000;">&#41;</span>
	<span style="color: #008000;">#EndRegion Main</span>
	<span style="color: #000000;">&#125;</span></pre></div></div>

<p>You can download it here: <a href="http://www.peetersonline.nl/wp-content/Set-VMSnapshotLocation.txt">Set-VMSnapshotLocation (rename to .ps1)</a></p>
<p>I tried hard as I could, but I could not get my vm to die. Even running the script, creating a snapshot, running the script to move the working location again and deleting the snapshot did not prove a problem. However, I urge you to be careful with it. I&#8217;m not responsable for anything you do with it.</p>
<p>Tiny glitch: the VI Client shows the wrong datastore location when a vm has a snapshot in a modified workingdir.</p>
<p>Enjoy.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/set-vmware-snapshot-location-with-powershell/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Create a vSwitch Port Overview with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 10:42:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[vSwitch]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=404</guid>
		<description><![CDATA[WARNING: VMware vmotion does not check wether there are sufficient ports available on the virtual switch on the destination host. Migrating a vm to a host with insufficient ports will cause the vmotion to complete without warnings, yet the virtual NIC will be disconnected! This issue is descripbed in this KB article. The solution to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>WARNING: <a href="http://www.vmware.com/" target='_blank'>VMware</a> vmotion does not check wether there are sufficient ports available on the virtual switch on the destination host. Migrating a vm to a host with insufficient ports will cause the vmotion to complete without warnings, yet the virtual NIC will be disconnected! This issue is descripbed in <a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&#038;docType=kc&#038;externalId=1009103&#038;sliceId=1&#038;docTypeID=DT_KB_1_1&#038;dialogID=26680233&#038;stateId=1%200%2026678654">this KB article</a>.<br />
The solution to this problem is to create vSwitches with sufficient ports, obviously. Do you want to know how many ports are currently being used on every vSwitch in your environment? <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> to the rescue! Try the following script:</p>
<p><span id="more-404"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800000;">&quot;MyVCServer&quot;</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VM</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>VM<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$NIC</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>NetworkAdapter <span style="color: pink;">-</span>VM <span style="color: #800080;">$VM</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$myObj</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> VMHost<span style="color: pink;">,</span> VM<span style="color: pink;">,</span> NIC<span style="color: pink;">,</span> PortGroup<span style="color: pink;">,</span> vSwitch
			<span style="color: #800080;">$myObj</span>.VMHost <span style="color: pink;">=</span> <span style="color: #800080;">$VMHost</span>.Name
			<span style="color: #800080;">$myObj</span>.VM <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span>.Name
			<span style="color: #800080;">$myObj</span>.NIC <span style="color: pink;">=</span> <span style="color: #800080;">$NIC</span>.Name
			<span style="color: #800080;">$myObj</span>.PortGroup <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VirtualPortGroup <span style="color: pink;">-</span>VM <span style="color: #800080;">$VM</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$NIC</span>.NetworkName
			<span style="color: #800080;">$myObj</span>.vSwitch <span style="color: pink;">=</span> <span style="color: #800080;">$myObj</span>.PortGroup.VirtualSwitchName
			<span style="color: #800080;">$myCol</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$myObj</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Group-Object</span> VMHost<span style="color: pink;">,</span> vSwitch <span style="color: #008080; font-style: italic;">-NoElement</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span> Count
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #008080; font-style: italic;">-Confirm</span>:$false</pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oneliner: Service Console IP with PowerCLI</title>
		<link>http://www.peetersonline.nl/index.php/vmware/oneliner-service-console-ip-with-powercli/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/oneliner-service-console-ip-with-powercli/#comments</comments>
		<pubDate>Tue, 26 May 2009 08:52:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oneliners]]></category>
		<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Service Console]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=380</guid>
		<description><![CDATA[Getting the Service Console IP addresses of your ESX servers with vSphere PowerCLI (formerly known as the VI Toolkit for Powershell): Get-VMHost &#124; Select Name, @&#123;N=&#34;ConsoleIP&#34;;E=&#123;&#40;Get-VMHostNetwork&#41;.ConsoleNic &#124; ForEach&#123;$_.IP&#125;&#125;&#125; No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Getting the Service Console IP addresses of your ESX servers with <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> (formerly known as the <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> for <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;ConsoleIP&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHostNetwork<span style="color: #000000;">&#41;</span>.ConsoleNic <span style="color: pink;">|</span> <span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.IP<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/oneliner-service-console-ip-with-powercli/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Translate Vml to LUN Path with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/translate-vml-to-lun-path-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/translate-vml-to-lun-path-with-powershell/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 10:01:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=365</guid>
		<description><![CDATA[While checking the vmkernel logs on our VMware ESX Servers today, I ran into some errors referencing luns using a vml string. It looks something like this: vml.827149017315617. I would like to know what lun this error is referencing, but I prefer the LUN Path notation, e.g.: vmhba1:2:137. So I wrote this Powershell VI Toolkit function [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>While checking the vmkernel logs on our <a href="http://www.vmware.com/" target='_blank'>VMware</a> ESX Servers today, I ran into some errors referencing luns using a vml string. It looks something like this: vml.827149017315617. I would like to know what lun this error is referencing, but I prefer the LUN Path notation, e.g.: vmhba1:2:137. So I wrote this <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> function that can translate the vml into the lun path:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Function: Translate a VML (e.g.: vml.9364839746917650) to a Lun Path (e.g.: vmhba1:2:137)</span>
&nbsp;
<span style="color: #0000FF;">function</span> Translate<span style="color: pink;">-</span>VmlToLunPath
	<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$VMHostName</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Vml</span>
	<span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">Return</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHost <span style="color: #800080;">$VMhostName</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>ScsiLun <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.ConsoleDeviceName <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$Vml</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.CanonicalName
	<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Feed it a host name and a vml string and it will return the lun path. Here&#8217;s an example script that uses this function when looking for LUNs with SCSI Reservation Errors:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Example use in a script: Get LUNs with SCSI Reservation Conflicts</span>
&nbsp;
<span style="color: #800080;">$VIServerName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;myVIServer&quot;</span>
<span style="color: #800080;">$NumLines</span> <span style="color: pink;">=</span> <span style="color: #000000;">1000</span>
&nbsp;
<span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$VIServerName</span>
&nbsp;
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: #0000FF;">in</span> Get<span style="color: pink;">-</span>VMHost<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Log</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>Log <span style="color: #008080; font-style: italic;">-Key</span> vmkernel <span style="color: pink;">-</span>NumLines <span style="color: #800080;">$NumLines</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$MatchedEntries</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Log</span>.Entries <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;reservation&quot;</span> <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;vml.\d*&quot;</span><span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VmlId</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$matches</span>.values<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$myObj</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> VMHost<span style="color: pink;">,</span> ErrorLun
			<span style="color: #800080;">$myObj</span>.VMHost <span style="color: pink;">=</span> <span style="color: #800080;">$VMHost</span>.Name
			<span style="color: #800080;">$myObj</span>.ErrorLun <span style="color: pink;">=</span> Translate<span style="color: pink;">-</span>VmlToLunPath <span style="color: pink;">-</span>VMHostName <span style="color: #800080;">$VMHost</span>.Name <span style="color: pink;">-</span>Vml <span style="color: #800080;">$VmlId</span>
			<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$myObj</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #008080; font-style: italic;">-Confirm</span>:$False</pre></div></div>

<p>Enjoy!<br />
Hugo</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/translate-vml-to-lun-path-with-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Checking VMware NTP configuration with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/checking-vmware-ntp-configuration-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/checking-vmware-ntp-configuration-with-powershell/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 08:37:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oneliners]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VI Toolkit 1.5]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[NTP]]></category>
		<category><![CDATA[Oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=288</guid>
		<description><![CDATA[Thanks to the VMware VI Toolkit 1.5, checking the NTP settings on all your VMware ESX Servers is as easy as a oneliner: Get-VMHost &#124; Sort Name &#124; Select Name, @{N=&#8221;NTP&#8221;;E={Get-VMHostNtpServer $_}} No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Thanks to the <a href="http://www.vmware.com/" target='_blank'>VMware</a> <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> 1.5, checking the NTP settings on all your <a href="http://www.vmware.com/" target='_blank'>VMware</a> ESX Servers is as easy as a oneliner:</p>
<blockquote><p>
Get-VMHost | Sort Name | Select Name, @{N=&#8221;NTP&#8221;;E={Get-VMHostNtpServer $_}}
</p></blockquote>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/checking-vmware-ntp-configuration-with-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VI Toolkit 1.5 Getting Started and Undocumented Functions</title>
		<link>http://www.peetersonline.nl/index.php/vmware/vi-toolkit-15-getting-started-and-undocumented-functions/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/vi-toolkit-15-getting-started-and-undocumented-functions/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 08:07:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VI Toolkit 1.5]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=286</guid>
		<description><![CDATA[0. Installing Installing or upgrading the VI Toolkit 1.5 is as easy as Next, Next, Finish. And using the new VI Toolkit shortcut on your desktop allows quick and easy access to the Toolkit. But what about running these cmdlets from your scripts or integrating it with other snapins? Read on! 1. Setting up your [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><strong>0. Installing</strong><br />
Installing or upgrading the <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> 1.5 is as easy as Next, Next, Finish. And using the new <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> shortcut on your desktop allows quick and easy access to the Toolkit. But what about running these cmdlets from your scripts or integrating it with other snapins? Read on!</p>
<p><strong>1. Setting up your profile</strong><br />
The new desktop shortcut does two things for you: it starts <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>powershell</a> with the <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> snapin loaded and it runs a script which modified the look of the <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> window ánd adds some cool extra functions. If you want to have the same functionality in your normal <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> window and your scripts, you have to copy some stuff to your <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> profile. First, set up your profile:</p>
<p>a. Start a normal <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> window.<br />
b. Run the following command: Test-Path $profile<br />
c. Did it return True? Then you already have a profile file. Did it return False, do step d.<br />
d. Create a profile file by running: New-Item $profile -ItemType File</p>
<p><strong>2. Adding the snap-in</strong><br />
a. Open your profile by running: Invoke-Item $profile<br />
b. Add the following line to the profile file to load the snap-in: <em>Add-PSSnapIn <a href="http://www.vmware.com/" target='_blank'>VMware</a>.VimAutomation.Core -ErrorAction SilentlyContinue</em></p>
<p><strong>3. Adding undocumented functions</strong><br />
a. Open the file <em>C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1</em><br />
b. Copy the following Function Blocks to your profile file: <em>Get-VICommand, New-DatastoreDrive, New-VIInventoryDrive, Get-VIToolkitDocumentation, Get-VIToolkitCommunity</em></p>
<p><strong>4. Undocumented Functions?<br />
</strong>Ok, you can read about them in the <em>Administrator&#8217;s Guide</em> (<a href="http://www.vmware.com/support/developer/windowstoolkit/wintk10/doc/viwin_admin.pdf">http://www.vmware.com/support/developer/windowstoolkit/wintk10/doc/viwin_admin.pdf</a>), but you might overlook these functions because they are not cmdlets, so <em>Get-Command</em> won&#8217;t show them (nor will Auto-Complete work for them).<br />
Here&#8217;s a short description of each of them:</p>
<ul>
<li><strong>Get-VICommand</strong>: Displays all <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> cmdlets (equal to: <em>Get-Command -PSSnapIn <a href="http://www.vmware.com/" target='_blank'>VMware</a>.VimAutomation.Core</em>);</li>
<li><strong>New-DatastoreDrive</strong>: Allows you to browse a datastore like a drive (Example Usage: <em>New-DatastoreDrive -Name &lt;DriveName&gt; -Datastore (Get-Datastore &lt;DatastoreName&gt;</em>); Then jump to the drive: <em>cd &lt;DriveName&gt;: </em>);</li>
<li><strong>New-VIInventoryDrive</strong>: Allows you to browse your Virtual Infrastructure like a drive (Example Usage: <em>New-VIInventoryDrive -Name &lt;DriveName&gt; -Location (Get-Inventory &lt;Folder-/Cluster-/ResourcePool-/HostName&gt;</em>); Then jump to drive: <em>cd &lt;DriveName&gt;:</em> );</li>
<li><strong>Get-VIToolkitDocumentation</strong>: Opens the <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> Command Reference Help File;</li>
<li><strong>Get-VIToolkitCommunity</strong>: Opens the <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a> Community website.</li>
</ul>
<p>More examples and scripts here soon!<br />
Hugo</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/vi-toolkit-15-getting-started-and-undocumented-functions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Check VMware Configuration with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 06:00:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[LUN]]></category>
		<category><![CDATA[portgroups]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=276</guid>
		<description><![CDATA[I have promised you I would post this script, so here it is! This Powershell script generates an overview of any items that are not available to every ESX server in a VMware cluster. These items might prevent your vm&#8217;s being vmotioned by DRS or restarted by HA. Pretty serious business, I&#8217;d say! The items [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I have <a href="http://www.peetersonline.nl/index.php/vmware/compare-cluster-datastores-with-powershell/">promised you</a> I would post this script, so here it is!</p>
<p>This <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> script generates an overview of any items that are not available to every ESX server in a <a href="http://www.vmware.com/" target='_blank'>VMware</a> cluster. These items might prevent your vm&#8217;s being vmotioned by DRS or restarted by HA. Pretty serious business, I&#8217;d say!</p>
<p>The items involved are:<br />
1. datastores<br />
2. LUNs (important when using Raw Device Mappings)<br />
3. port groups</p>
<p>The output is a nicely formatted HTML page showing not only which items are misconfigured, but also where the are available and where they are absent.</p>
<p>Here&#8217;s an example:<br />
<a href="http://www.peetersonline.nl/wp-content/capture.jpg"><img class="alignnone size-full wp-image-274" title="Compare Screenshot" src="http://www.peetersonline.nl/wp-content/capture.jpg" alt="Compare Screenshot" width="385" height="272" /></a></p>
<p>And here&#8217;s the script:<br />
<a href="http://www.peetersonline.nl/wp-content/compare-clusters.txt">Compare-Clusters (Rename to .ps1)</a></p>
<p>Enjoy!<br />
Hugo</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Compare Cluster Datastores with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/compare-cluster-datastores-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/compare-cluster-datastores-with-powershell/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 14:00:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=267</guid>
		<description><![CDATA[I showed you before how to compare the datastores for two ESX Servers using the VI Toolkit. But ideally, one would like to compare all ESX servers in a cluster to ensure VMotion and HA compatibility. So I started scripting and it turns out to be pretty simple: only 4 lines of code in Powershell! [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://www.peetersonline.nl/index.php/vmware/compare-esx-configurations-with-powershell/">showed you before</a> how to compare the datastores for two ESX Servers using the <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a>. But ideally, one would like to compare all ESX servers in a cluster to ensure VMotion and HA compatibility.<br />
So I started scripting and it turns out to be pretty simple: only 4 lines of code in <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a>! It does the comparison for all your clusters and returns clean little tables with datastores you should investigate.</p>
<p>SCRIPT CODE:</p>
<blockquote><p>ForEach ($Cluster in (Get-Cluster | Sort Name))<br />
{<br />
$VMHosts = Get-Cluster $Cluster.Name | Get-VMHost<br />
$Datastores = $VMHosts | Get-Datastore<br />
$VMHosts | ForEach {Compare-Object $Datastores ($_ | Get-Datastore)} | ForEach {$_.InputObject} | Sort Name | Select @{N=$Cluster.Name;E={$_.Name}} -Unique | Format-Table<br />
}</p></blockquote>
<p>SAMPLE OUTPUT:</p>
<blockquote><p>TEST CLUSTER 1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
DATASTORE1<br />
LOCAL01<br />
LOCAL02<br />
LOCAL03</p>
<p>TEST CLUSTER 2<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
DATASTORE2<br />
DATASTORE3<br />
LOCAL06<br />
LOCAL07<br />
LOCAL08<br />
LOCAL09</p></blockquote>
<p>Coming very soon: a full-blown script that compares datastores, LUNs and portgroups across your clusters ánd identifies exactly where the differences are! Stay tuned&#8230;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/compare-cluster-datastores-with-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Another way to gather VMware disk info with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/another-way-to-gather-vmware-disk-info-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/another-way-to-gather-vmware-disk-info-with-powershell/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 07:55:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[disks]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=227</guid>
		<description><![CDATA[I&#8217;ve created another way to gather and display VMware Virtual Disk information with the Powershell VI Toolkit. The attached script generates a csv-file with all Virtual Machines&#8217; Disks, in which Datastore they are stored, the LUN IDs of the extents that make up this Datastore (in HEX) and the Vendor of the SAN those LUNs [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created another way to gather and display <a href="http://www.vmware.com/" target='_blank'>VMware</a> Virtual Disk information with the <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> <a href="http://www.vmware.com/sdk/vitk_win/index.html" target='_blank'>VI Toolkit</a>.</p>
<p>The attached script generates a csv-file with all Virtual Machines&#8217; Disks, in which Datastore they are stored, the LUN IDs of the extents that make up this Datastore (in HEX) and the Vendor of the SAN those LUNs are on (just in case you have multiple). Simpy a great way to determine which LUNs are used by which virtual server(s) in a complex environment.</p>
<p><a href="http://www.peetersonline.nl/wp-content/diskinfo.jpg"><img class="alignnone size-full wp-image-226" title="diskinfo" src="http://www.peetersonline.nl/wp-content/diskinfo.jpg" alt="diskinfo" width="712" height="105" /></a></p>
<p>By the way: the script is filled with comments to allow you to learn how it works.</p>
<p><a href="http://www.peetersonline.nl/wp-content/create-vmdiskoverview.txt">create-vmdiskoverview (Rename to .ps1)</a></p>
<p>Enjoy!</p>
<p>Hugo</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/another-way-to-gather-vmware-disk-info-with-powershell/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Compare ESX configurations with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/compare-esx-configurations-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/compare-esx-configurations-with-powershell/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 08:00:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[portgroups]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=221</guid>
		<description><![CDATA[One of the challenges in managing a large VMware Infrastructure is keeping all ESX Servers within a cluster equal. This is essential for having vmotion capabilities and therefore essential for a solid HA configuration. I have showed you earlier how to add the LUN Count for each ESX Server to your VI Client. This allows you [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>One of the challenges in managing a large <a href="http://www.vmware.com/" target='_blank'>VMware</a> Infrastructure is keeping all ESX Servers within a cluster equal. This is essential for having vmotion capabilities and therefore essential for a solid HA configuration. I have <a href="http://www.peetersonline.nl/index.php/vmware/add-snapshot-information-to-the-vi-client-using-powershell/">showed you earlier</a> how to add the <a href="http://www.peetersonline.nl/index.php/vmware/add-custom-fields-to-vi-client-with-powershell-samples/">LUN Count</a> for each ESX Server to your VI Client. This allows you to spot differences quickly. But finding exactly which datastores are missing on which ESX Server can be a bigger challenge.</p>
<p>Here are some small functions that can help you determine where the major differences are.</p>
<p>Comparing datastores:</p>
<blockquote><p>function Compare-VMHostDatastores<br />
{<br />
param([string]$host1,[string]$host2)<br />
$a = Get-VMHost $host1 | Get-Datastore | %{$_.Name}<br />
$b = Get-VMHost $host2 | Get-Datastore | %{$_.Name}<br />
Compare-Object $a $b<br />
}</p></blockquote>
<blockquote><p>Compare-VMHostDatastores esxServer1 esxServer2</p>
<p>InputObject                         SideIndicator<br />
&#8212;&#8212;&#8212;&#8211;                                &#8212;&#8212;&#8212;&#8212;-<br />
esxServer1_Local             &lt;=<br />
esxServer2_Local             =&gt;<br />
DATASTORE_TEST1         =&gt;</p></blockquote>
<p>And comparing Port Groups:</p>
<blockquote><p>function Compare-VMHostPortgroups<br />
{<br />
param([string]$host1,[string]$host2)<br />
$a = Get-VirtualPortGroup (Get-VMHost $host1) | %{$_.Name}<br />
$b = Get-VirtualPortGroup (Get-VMHost $host2) | %{$_.Name}<br />
Compare-Object $a $b<br />
}</p></blockquote>
<blockquote><p>Compare-VMHostPortgroups esxServer1 esxServer2</p>
<p>InputObject                SideIndicator<br />
&#8212;&#8212;&#8212;&#8211;                      &#8212;&#8212;&#8212;&#8212;-<br />
PortGroup_TEST     &lt;=<br />
Internal                       &lt;=</p></blockquote>
<p>Maybe you prefer to go the other way around and check to which ESX servers a specific datastore is attached?</p>
<blockquote><p>function Get-DatastoreHosts<br />
{<br />
param([string]$datastore)<br />
Get-VMHost -Datastore (Get-Datastore $datastore) | Sort Name | %{$_.Name}<br />
}</p></blockquote>
<blockquote><p>PS D:Scripts&gt; Get-DatastoreHosts DATASTORE_TEST1</p>
<p>esxServer2<br />
esxServer3</p></blockquote>
<p>Thank <a href="http://www.microsoft.com" target='_blank'>Microsoft</a> for <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> and the Compare-Object cmdlet!</p>
<p>Hugo</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/compare-esx-configurations-with-powershell/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
