<?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; datastores</title>
	<atom:link href="http://www.peetersonline.nl/index.php/tag/datastores/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peetersonline.nl</link>
	<description>Using Powershell for (virtually) everything!</description>
	<lastBuildDate>Fri, 19 Aug 2011 09:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Find LUN ID&#8217;s in VMware with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/find-lun-ids-in-vmware-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/find-lun-ids-in-vmware-with-powershell/#comments</comments>
		<pubDate>Thu, 27 May 2010 08:01:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[LUN ID]]></category>
		<category><![CDATA[Luns]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=457</guid>
		<description><![CDATA[Determining the LUN ID for a specific LUN in your VMware Infrastructure used to be simple. It was listed as one of the properties of the datastore you selected in the VI Client. Nowadays, more often than not, I dont see the LUN ID in the vSphere Client. Instead, I see some sort of identifier <a href='http://www.peetersonline.nl/index.php/vmware/find-lun-ids-in-vmware-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Determining the LUN ID for a specific LUN in your <a href="http://www.vmware.com/" target='_blank'>VMware</a> Infrastructure used to be simple. It was listed as one of the properties of the datastore you selected in the VI Client. Nowadays, more often than not, I dont see the LUN ID in the <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> Client. Instead, I see some sort of identifier like &#8220;EMC Fibre Channel Disk (sym.12673548127)&#8221;.<br />
Even more unfortunate is the fact that all my scripts show the same identifier, where they used to show the LUN ID. So I decided to create a script that can translate the identifier (sometimes referred to as Canonical Name) back to a LUN ID.<br />
By the way: in the <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> Client, you can still find the LUN ID by opening the datastore&#8217;s properties window and clicking Manage Paths. Or you could write down the canonical name, switch to the devices view and look up the device there. That is essentially what my script does for you.<br />
Here we go:<br />
<span id="more-457"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #0000FF;">function</span> Get<span style="color: pink;">-</span>LunId
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$CanonicalName</span><span style="color: pink;">,</span> <span style="color: #800080;">$VMHost</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;">#Get advanced host properties</span>
	<span style="color: #800080;">$VMHostView</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VMHost <span style="color: #800080;">$VMHost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View
&nbsp;
	<span style="color: #008000;">#Get two different collections with luns</span>
	<span style="color: #008000;">#The first one matches the canonical name with a key</span>
	<span style="color: #800080;">$HostLunsByCanonicalName</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VMHost <span style="color: #800080;">$VMHost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>SCSILun
	<span style="color: #008000;">#The second one matches the key with a lun id</span>
	<span style="color: #800080;">$HostLunsByKey</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VMHostView</span>.Config.StorageDevice.ScsiTopology <span style="color: pink;">|</span> 
		<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Adapter<span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Target<span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Lun<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #008000;">#Use the first collection to translate the canonicalname into the key</span>
	<span style="color: #800080;">$Key</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$HostLunsByCanonicalName</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.CanonicalName <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$CanonicalName</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.Key
	<span style="color: #008000;">#Use the second colleciton to find the luns with the key</span>
	<span style="color: #800080;">$MatchingLuns</span> <span style="color: pink;">=</span> <span style="color: #800080;">$HostLunsByKey</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.ScsiLun <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$Key</span><span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #008000;">#Every path to the lun will be a match, </span>
	<span style="color: #008000;">#so let's deduplicate and see if there is really a single result</span>
	<span style="color: #800080;">$NumResults</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$MatchingLuns</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Group-Object</span> Lun <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span><span style="color: #000000;">&#41;</span>.Count
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$NumResults</span> <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;">#Multiple luns found</span>
		<span style="color: #800080;">$MatchingLuns</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Group-Object</span> Lun <span style="color: pink;">|</span> <span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">ElseIf</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$NumResults</span> <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;">#Single result found</span>
		<span style="color: #000000;">&#40;</span><span style="color: #800080;">$MatchingLuns</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> <span style="color: #008080; font-style: italic;">-First</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>.Lun
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;">#No results found</span>
		<span style="color: #800000;">&quot;No result&quot;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Download the script here: <a href='http://www.peetersonline.nl/wp-content/Get-LunId.txt'>Get-LunId (rename to *.ps1)</a></p>
<p>Note that when you use this function inside a script where you loop through several LUNs/VMs/Datastores on the same host, you are able to speed up your script significantly by taking the Get-VMHost $VMHost | Get-View part outside of the function.</p>
<p>Enjoy!<br />
Hugo</p>
<p>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/find-lun-ids-in-vmware-with-powershell/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 <a href='http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol>]]></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>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/feed/</wfw:commentRss>
		<slash:comments>23</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! <a href='http://www.peetersonline.nl/index.php/vmware/compare-cluster-datastores-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol>]]></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>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol></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 <a href='http://www.peetersonline.nl/index.php/vmware/another-way-to-gather-vmware-disk-info-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol>]]></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>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol></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>28</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 <a href='http://www.peetersonline.nl/index.php/vmware/compare-esx-configurations-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
</ol>]]></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>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
</ol></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>
		<item>
		<title>Get VMware Disk Usage with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 12:17:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[Disk Usage]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[VI Toolkit]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/</guid>
		<description><![CDATA[Using VMware seriously requires a lot of (shared) storage. This kind of storage (on a SAN for instance) is quite expensive. So you might want to check if you are wasting a lot of this space. When you look at the storage in VMware, it consists of multiple abstraction layers. A virtual machine has one <a href='http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Using <a href="http://www.vmware.com/" target='_blank'>VMware</a> seriously requires a lot of (shared) storage. This kind of storage (on a SAN for instance) is quite expensive. So you might want to check if you are wasting a lot of this space. When you look at the storage in <a href="http://www.vmware.com/" target='_blank'>VMware</a>, it consists of multiple abstraction layers. A virtual machine has one or more Logical Disks, which are indicated by driveletters. You can use WMI to determine the amount of used and free space (Win32_LogicalDisk). One or more logical disks are contained in a partition. One or more partitions reside on a physical disk. That physical disk is really a virtual disk, a vmdk file to be precise. One or more vmdk files reside in a Datastore, which can be found on a LUN on your SAN.<br />
The following script enumerates most of these layers (from logical disk to datastore) and calculates the used and free space. The final line exports the results to a csv file for use in Excel. And the script also helps you to calculate the average free space by showing the totals without the duplicates (don&#8217;t try to average the averages in excel, that&#8217;s not accurate because datastores contain duplicates and averages should be weighed).</p>
<p><strong>UPDATE: I have modified the script, so no more matching of disks is done based on disk size. The match is made based on SCSI IDs and WMI relations. Thanks to adavidm on the VI Toolkit Community</strong><span id="more-118"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#Get VMware Disk Usage</span>
<span style="color: #008000;"># Created by Hugo Peeters</span>
<span style="color: #008000;"># http://www.peetersonline.nl</span>
<span style="color: #008000;"># VARIABLES</span>
<span style="color: #800080;">$Decimals</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span>
<span style="color: #800080;">$VCServer</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;MYVCSERVER&quot;</span>
<span style="color: #008000;"># SCRIPT</span>
<span style="color: #008000;"># Connect to VC</span>
<span style="color: #008080; font-weight: bold;">Write-Progress</span> <span style="color: #800000;">&quot;Gathering Information&quot;</span> <span style="color: #800000;">&quot;Connecting to Virtual Center&quot;</span> <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$VCServer</span>
<span style="color: #008000;"># Create Output Collection</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: #008000;"># List Datastores (Datastore Name)</span>
<span style="color: #008080; font-weight: bold;">Write-Progress</span> <span style="color: #800000;">&quot;Gathering Information&quot;</span> <span style="color: #800000;">&quot;Listing Datastores&quot;</span> <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$Datastores</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>Datastore <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name
<span style="color: #008000;"># List vms</span>
<span style="color: #008080; font-weight: bold;">Write-Progress</span> <span style="color: #800000;">&quot;Gathering Information&quot;</span> <span style="color: #800000;">&quot;Listing VMs and Disk Files&quot;</span> <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$VMSummaries</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;">$vm</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</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: #800080;">$VMView</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View
	<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VirtualSCSIController</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMView</span>.Config.Hardware.Device <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.DeviceInfo.Label <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;SCSI Controller&quot;</span><span style="color: #000000;">&#125;</span><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;">$VirtualDiskDevice</span>  <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMView</span>.Config.Hardware.Device <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.ControllerKey <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$VirtualSCSIController</span>.Key<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$VMSummary</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> VM<span style="color: pink;">,</span> HostName<span style="color: pink;">,</span> PowerState<span style="color: pink;">,</span> DiskFile<span style="color: pink;">,</span> DiskName<span style="color: pink;">,</span> DiskSize<span style="color: pink;">,</span> SCSIController<span style="color: pink;">,</span> SCSITarget
			<span style="color: #800080;">$VMSummary</span>.VM <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span>.Name
			<span style="color: #800080;">$VMSummary</span>.HostName <span style="color: pink;">=</span> <span style="color: #800080;">$VMView</span>.Guest.HostName
			<span style="color: #800080;">$VMSummary</span>.PowerState <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span>.PowerState
			<span style="color: #800080;">$VMSummary</span>.DiskFile <span style="color: pink;">=</span> <span style="color: #800080;">$VirtualDiskDevice</span>.Backing.FileName
			<span style="color: #800080;">$VMSummary</span>.DiskName <span style="color: pink;">=</span> <span style="color: #800080;">$VirtualDiskDevice</span>.DeviceInfo.Label
			<span style="color: #800080;">$VMSummary</span>.DiskSize <span style="color: pink;">=</span> <span style="color: #800080;">$VirtualDiskDevice</span>.CapacityInKB <span style="color: pink;">*</span> 1KB
			<span style="color: #800080;">$VMSummary</span>.SCSIController <span style="color: pink;">=</span> <span style="color: #800080;">$VirtualSCSIController</span>.BusNumber
			<span style="color: #800080;">$VMSummary</span>.SCSITarget <span style="color: pink;">=</span> <span style="color: #800080;">$VirtualDiskDevice</span>.UnitNumber
			<span style="color: #800080;">$VMSummaries</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$VMSummary</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #008080; font-weight: bold;">Clear-Variable</span> VMView <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
	<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># Loop through Datastores</span>
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Datastore</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Datastores</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># List vmdk files in datastore (vmdk Name)</span>
	<span style="color: #008080; font-weight: bold;">Write-Progress</span> <span style="color: #800000;">&quot;Gathering Information&quot;</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Processing Datastore {0}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$Datastore</span>.Name<span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #804000;">0</span>
	<span style="color: #800080;">$DSView</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Datastore</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View
	<span style="color: #800080;">$fileQueryFlags</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.FileQueryFlags
	<span style="color: #800080;">$fileQueryFlags</span>.FileSize <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
	<span style="color: #800080;">$fileQueryFlags</span>.FileType <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
	<span style="color: #800080;">$fileQueryFlags</span>.Modification <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
	<span style="color: #800080;">$searchSpec</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.HostDatastoreBrowserSearchSpec
	<span style="color: #800080;">$searchSpec</span>.details <span style="color: pink;">=</span> <span style="color: #800080;">$fileQueryFlags</span>
	<span style="color: #800080;">$searchSpec</span>.sortFoldersFirst <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
	<span style="color: #800080;">$dsBrowser</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #800080;">$DSView</span>.browser
	<span style="color: #800080;">$rootPath</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;[&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$DSView</span>.summary.Name<span style="color: pink;">+</span><span style="color: #800000;">&quot;]&quot;</span>
	<span style="color: #800080;">$searchResult</span> <span style="color: pink;">=</span> <span style="color: #800080;">$dsBrowser</span>.SearchDatastoreSubFolders<span style="color: #000000;">&#40;</span><span style="color: #800080;">$rootPath</span><span style="color: pink;">,</span> <span style="color: #800080;">$searchSpec</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$result</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$searchResult</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;">$vmdk</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$result</span>.File <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Path <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;*.vmdk&quot;</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Path<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #008080; font-weight: bold;">Write-Progress</span> <span style="color: #800000;">&quot;Gathering Information&quot;</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Processing VMDK {0}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$vmdk</span>.Path<span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #804000;">1</span>
			<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;==============================================================================&quot;</span>
			<span style="color: #008000;"># Find vm using the vmdk (VM Name)</span>
			<span style="color: #800080;">$VMRef</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMSummaries</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.DiskFile <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$Datastore</span>.Name <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.DiskFile <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$vmdk</span>.Path<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800000;">&quot;VMDK {0} belongs to VM {1}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$vmdk</span>.Path<span style="color: pink;">,</span> <span style="color: #800080;">$VMRef</span>.VM
			<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMRef</span>.Powerstate <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;PoweredOn&quot;</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
				<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;VM is powered on&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
				<span style="color: #800080;">$Partitions</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_DiskPartition <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$VMRef</span>.HostName
				<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000080;">$?</span><span style="color: #000000;">&#41;</span>
					<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$Disks</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_DiskDrive <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$VMRef</span>.HostName
					<span style="color: #800080;">$LogicalDisks</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_LogicalDisk <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$VMRef</span>.HostName
					<span style="color: #800080;">$DiskToPartition</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_DiskDriveToDiskPartition <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$VMRef</span>.HostName
					<span style="color: #800080;">$LogicalDiskToPartition</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_LogicalDiskToPartition <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$VMRef</span>.HostName
					<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Read partition and disk information&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
					<span style="color: #008000;"># Match disk based on SCSI ID's</span>
					<span style="color: #800080;">$DiskMatch</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Disks</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.SCSIPort <span style="color: pink;">-</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$VMRef</span>.SCSIController <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.SCSITargetID <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$VMRef</span>.SCSITarget<span style="color: #000000;">&#125;</span>
					<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DiskMatch</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;NO MATCHES!&quot;</span><span style="color: #000000;">&#125;</span>
					<span style="color: #0000FF;">Else</span>
						<span style="color: #000000;">&#123;</span>
						<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Found match:&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
						<span style="color: #800080;">$DiskMatch</span>
						<span style="color: #008000;"># Find the Partition(s) on this disk</span>
						<span style="color: #800080;">$PartitionsOnDisk</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DiskToPartition</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Antecedent <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$DiskMatch</span>.__PATH<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
						<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$PartitionsOnDisk</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;NO PARTITIONS!&quot;</span><span style="color: #000000;">&#125;</span>
						<span style="color: #0000FF;">Else</span>
							<span style="color: #000000;">&#123;</span>
							<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$PartitionOnDisk</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$PartitionsOnDisk</span><span style="color: #000000;">&#41;</span>
								<span style="color: #000000;">&#123;</span>
								<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Disk contains partition&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
								<span style="color: #800080;">$PartitionOnDisk</span>.Dependent
								<span style="color: #800080;">$PartitionMatches</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Partitions</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.__PATH <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$PartitionOnDisk</span>.Dependent<span style="color: #000000;">&#125;</span>
								<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$PartitionMatch</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$PartitionMatches</span><span style="color: #000000;">&#41;</span>
									<span style="color: #000000;">&#123;</span>
									<span style="color: #800080;">$LogicalDiskRefs</span> <span style="color: pink;">=</span> <span style="color: #800080;">$LogicalDiskToPartition</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Antecedent <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$PartitionMatch</span>.__PATH<span style="color: #000000;">&#125;</span>
									<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskRefs</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
										<span style="color: #000000;">&#123;</span>
										<span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;NO LOGICAL DISKS!&quot;</span>
										<span style="color: #000000;">&#125;</span>
									<span style="color: #0000FF;">Else</span>
										<span style="color: #000000;">&#123;</span>
										<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskRef</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$LogicalDiskRefs</span><span style="color: #000000;">&#41;</span>
											<span style="color: #000000;">&#123;</span>
											<span style="color: #800080;">$LogicalDiskMatches</span> <span style="color: pink;">=</span> <span style="color: #800080;">$LogicalDisks</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.__PATH <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$LogicalDiskRef</span>.Dependent<span style="color: #000000;">&#125;</span>
											<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskMatch</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$LogicalDiskMatches</span><span style="color: #000000;">&#41;</span>
												<span style="color: #000000;">&#123;</span>
												<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Matching Logical Disk:&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
												<span style="color: #800080;">$LogicalDiskMatch</span>
												<span style="color: #008000;"># Create Output Object</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> Datastore<span style="color: pink;">,</span> DSSizeGB<span style="color: pink;">,</span> DSFreeGB<span style="color: pink;">,</span> DSPercentFree<span style="color: pink;">,</span> DiskFile<span style="color: pink;">,</span> VM<span style="color: pink;">,</span> HardDisk<span style="color: pink;">,</span> DriveLetter<span style="color: pink;">,</span> DiskSizeGB<span style="color: pink;">,</span> DiskFreeGB<span style="color: pink;">,</span> PercFree
												<span style="color: #008000;"># List datastore name</span>
												<span style="color: #800080;">$myObj</span>.Datastore <span style="color: pink;">=</span> <span style="color: #800080;">$Datastore</span>.Name
												<span style="color: #008000;"># Determine datastore size in GB</span>
												<span style="color: #800080;">$myObj</span>.DSSizeGB <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Datastore</span>.CapacityMB <span style="color: pink;">*</span> 1MB <span style="color: pink;">/</span> 1GB<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
												<span style="color: #800080;">$myObj</span>.DSFreeGB <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Datastore</span>.FreeSpaceMB <span style="color: pink;">*</span> 1MB <span style="color: pink;">/</span> 1GB<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
												<span style="color: #008000;"># Determine datastore free space (DS%Free)</span>
												<span style="color: #800080;">$myObj</span>.DSPercentFree <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #804000;">100</span><span style="color: pink;">*</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Datastore</span>.FreeSpaceMB<span style="color: pink;">/</span><span style="color: #800080;">$Datastore</span>.CapacityMB<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
												<span style="color: #008000;"># List disk file name</span>
												<span style="color: #800080;">$myObj</span>.DiskFile <span style="color: pink;">=</span> <span style="color: #800080;">$vmdk</span>.Path
												<span style="color: #008000;"># List VM Name</span>
												<span style="color: #800080;">$myObj</span>.VM <span style="color: pink;">=</span> <span style="color: #800080;">$VMRef</span>.VM
												<span style="color: #008000;"># Determine virtual hard disk / logical drive</span>
												<span style="color: #800080;">$myObj</span>.HardDisk <span style="color: pink;">=</span> <span style="color: #800080;">$VMRef</span>.DiskName
												<span style="color: #008000;"># Report driveletter</span>
												<span style="color: #800080;">$myObj</span>.DriveLetter <span style="color: pink;">=</span> <span style="color: #800080;">$LogicalDiskMatch</span>.DeviceID
												<span style="color: #008000;"># Report Size</span>
												<span style="color: #800080;">$myObj</span>.DiskSizeGB <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskMatch</span>.Size <span style="color: pink;">/</span> 1GB<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
												<span style="color: #008000;"># Report Free Space</span>
												<span style="color: #800080;">$myObj</span>.DiskFreeGB <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskMatch</span>.FreeSpace <span style="color: pink;">/</span> 1GB<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
												<span style="color: #008000;"># Calculate Percentage free space</span>
												<span style="color: #800080;">$myObj</span>.PercFree <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #804000;">100</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskMatch</span>.FreeSpace <span style="color: pink;">/</span> 1MB<span style="color: #000000;">&#41;</span> <span style="color: pink;">/</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$LogicalDiskMatch</span>.Size <span style="color: pink;">/</span> 1MB<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
												<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;RESULT:&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
												<span style="color: #800080;">$myObj</span>
												<span style="color: #008000;"># Add output object to output collection</span>
												<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: #008080; font-weight: bold;">Clear-Variable</span> LogicalDiskMatches <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
											<span style="color: #000000;">&#125;</span>
										<span style="color: #000000;">&#125;</span>
									<span style="color: #008080; font-weight: bold;">Clear-Variable</span> LogicalDiskRefs <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
									<span style="color: #000000;">&#125;</span>
								<span style="color: #008080; font-weight: bold;">Clear-Variable</span> PartitionMatches <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
								<span style="color: #000000;">&#125;</span>
							<span style="color: #000000;">&#125;</span>
						<span style="color: #008080; font-weight: bold;">Clear-Variable</span> PartitionsOnDisk <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
						<span style="color: #000000;">&#125;</span>
					<span style="color: #008080; font-weight: bold;">Clear-Variable</span> DiskMatch <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
					<span style="color: #008080; font-weight: bold;">Clear-Variable</span> Disks <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
					<span style="color: #008080; font-weight: bold;">Clear-Variable</span> LogicalDisks <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
					<span style="color: #008080; font-weight: bold;">Clear-Variable</span> DiskToPartition <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
					<span style="color: #008080; font-weight: bold;">Clear-Variable</span> LogicalDiskToPartition <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
					<span style="color: #000000;">&#125;</span>
				<span style="color: #008080; font-weight: bold;">Clear-Variable</span> Partitions <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
				<span style="color: #000000;">&#125;</span>
			<span style="color: #0000FF;">Else</span>
				<span style="color: #000000;">&#123;</span>
				<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;VM is powered off&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> <span style="color: #800000;">&quot;yellow&quot;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #008080; font-weight: bold;">Clear-Variable</span> VMRef <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
			<span style="color: #008080; font-weight: bold;">Write-Progress</span> <span style="color: #800000;">&quot;Gathering Information&quot;</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Processing VMDK {0}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$vmdk</span>.Path<span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #804000;">1</span> <span style="color: #008080; font-style: italic;">-Completed</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># Disconnect from VC</span>
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$False</span>
<span style="color: #008000;"># OUTPUT</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;===================================================&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;===================================================&quot;</span>
<span style="color: #800080;">$TotalDSFree</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Datastore<span style="color: pink;">,</span> DSFreeGB <span style="color: #008080; font-style: italic;">-Unique</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> DSFreeGB <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.Sum
<span style="color: #800080;">$TotalDSSize</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Datastore<span style="color: pink;">,</span> DSSizeGB <span style="color: #008080; font-style: italic;">-Unique</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> DSSizeGB <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.Sum
<span style="color: #800080;">$AverageDSFree</span> <span style="color: pink;">=</span>  <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #804000;">100</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$TotalDSFree</span> <span style="color: pink;">/</span> <span style="color: #800080;">$TotalDSSize</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$AverageDiskFree</span> <span style="color: pink;">=</span>  <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #804000;">100</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> DiskFreeGB <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.Sum <span style="color: pink;">/</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> DiskSizeGB <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.Sum<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Decimals</span><span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Total DS Free: $TotalDSFree&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Total DS Size: $TotalDSSize&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Average DS Free Percentage: $AverageDSFree&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Average Disk Free Percentage: $AverageDiskFree&quot;</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Export-Csv</span> <span style="color: #008080; font-style: italic;">-NoTypeInformation</span> <span style="color: #800000;">'P:\#TEMP\VMwareDiskUsage.csv'</span></pre></div></div>

<p>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/feed/</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
		<item>
		<title>Helpful scripts of the day: HTML Overview of VMs and Datastores</title>
		<link>http://www.peetersonline.nl/index.php/vmware/helpful-scripts-of-the-day-html-overview-of-vms-and-datastores/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/helpful-scripts-of-the-day-html-overview-of-vms-and-datastores/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 09:40:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[ConvertTo-HTML]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[overview]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[reporting]]></category>
		<category><![CDATA[VI Toolkit]]></category>
		<category><![CDATA[vms]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/index.php/vmware/helpful-scripts-of-the-day-html-overview-of-vms-and-datastores/</guid>
		<description><![CDATA[Today&#8217;s helpful scripts are ready to use scripts that generate an overview of your VM&#8217;s and your Datastores and save it to a HTML file. Great for reporting purposes. Easy to modify to meet your needs. Give them a try: Get-DatastoreSizes (Rename to .ps1) This one shows datastores with Used Space in GB, Free Space <a href='http://www.peetersonline.nl/index.php/vmware/helpful-scripts-of-the-day-html-overview-of-vms-and-datastores/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s helpful scripts are ready to use scripts that generate an overview of your VM&#8217;s and your Datastores and save it to a HTML file. Great for reporting purposes. Easy to modify to meet your needs. Give them a try:</p>
<p><a href="http://www.peetersonline.nl/wp-content/get-datastoresizes.txt" title="Get-DatastoreSizes (Rename to .ps1)">Get-DatastoreSizes (Rename to .ps1)</a></p>
<p>This one shows datastores with Used Space in GB, Free Space in GB and % Free Space.</p>
<p><a href="http://www.peetersonline.nl/wp-content/export-vms.txt" title="Export-VMs (Rename to .ps1)">Export-VMs (Rename to .ps1)</a></p>
<p>This one shows vm&#8217;s with OS Name, Total Disk Size in GB and Memory Size in GB.</p>
<p>Enjoy! </p>
<p>Hugo</p>
<p>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/helpful-scripts-of-the-day-html-overview-of-vms-and-datastores/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Powershell Oneliner #6</title>
		<link>http://www.peetersonline.nl/index.php/vmware/powershell-oneliner-6/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/powershell-oneliner-6/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 08:24:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oneliners]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/index.php/vmware/powershell-oneliner-6/</guid>
		<description><![CDATA[Today&#8217;s oneliner is an incredibly fast way to check the usage of your VMware datastores. You should first connect to Virtual Center in the following way: $VC = Connect-VIServer &#8220;YourVCServerName&#8221; Here comes the oneliner: Get-Datastore &#124; Sort-Object Name &#124; %{Get-View $_.Id} &#124; Format-Table @{Label=&#8221;Name&#8221;;Expression={$_.info.name}}, @{Label=&#8221;NumVMs&#8221;;Expression={$_.vm.length}} Only interested in datastores that are not used? Use the <a href='http://www.peetersonline.nl/index.php/vmware/powershell-oneliner-6/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s oneliner is an incredibly fast way to check the usage of your <a href="http://www.vmware.com/" target='_blank'>VMware</a> datastores. You should first connect to Virtual Center in the following way:</p>
<blockquote><p>$VC = Connect-VIServer &#8220;YourVCServerName&#8221;</p></blockquote>
<p>Here comes the oneliner:</p>
<blockquote><p>Get-Datastore | Sort-Object Name | %{Get-View $_.Id} | Format-Table @{Label=&#8221;Name&#8221;;Expression={$_.info.name}}, @{Label=&#8221;NumVMs&#8221;;Expression={$_.vm.length}}</p></blockquote>
<p>Only interested in datastores that are not used? Use the <em>Where-Object</em> cmdlet:</p>
<blockquote><p>Get-Datastore | Sort-Object Name | %{Get-View $_.Id} | Where {$_.vm.length -eq 0} | Format-Table @{Label=&#8221;Name&#8221;;Expression={$_.info.name}}, @{Label=&#8221;NumVMs&#8221;;Expression={$_.vm.length}}</p></blockquote>
<p>But watch out! Consider a vm with a disk in datastore A and the vmx in datastore B. When you create a snapshot of the vm, the delta files of all disks will be stored with the vmx (in datastore B). The script (as does the VI Client) will show the vm to be <strong>not connected</strong> to datastore A!</p>
<p>Enjoy!</p>
<p>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/powershell-oneliner-6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Where&#8217;s that vmdk at?</title>
		<link>http://www.peetersonline.nl/index.php/vmware/wheres-that-vmdk-at/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/wheres-that-vmdk-at/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 13:40:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[datastores]]></category>
		<category><![CDATA[locations]]></category>
		<category><![CDATA[vmdk]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/index.php/vmware/wheres-that-vmdk-at/</guid>
		<description><![CDATA[Do your vm&#8217;s have multiple virtual disks? Do you use different datastores for your vmdk&#8217;s? Are you ever wondering where the disk files of each of your vm&#8217;s is stored? Yes? Well, I&#8217;ve got something to help you out. Today&#8217;s handy script of the day creates an overview of the locations of all your vmdk <a href='http://www.peetersonline.nl/index.php/vmware/wheres-that-vmdk-at/'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Do your vm&#8217;s have multiple virtual disks? Do you use different datastores for your vmdk&#8217;s? Are you ever wondering where the disk files of each of your vm&#8217;s is stored? Yes? Well, I&#8217;ve got something to help you out.</p>
<p>Today&#8217;s handy script of the day creates an overview of the locations of all your vmdk files in the form of a csv file.</p>
<p>Of course you <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> guru&#8217;s can work some simple magic to output it to a HTML page, a Word document of straight to the printer. (If you don&#8217;t, but would like to, drop me a comment and I&#8217;ll try to respond asap).</p>
<p>The script is attached for easy use. Just fill in your Virtual Center server name, rename the file to .ps1 and enjoy!</p>
<p><a href="http://www.peetersonline.nl/wp-content/get-diskfiles.txt" title="Get-DiskFiles">Get-DiskFiles</a></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/wheres-that-vmdk-at/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

