<?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>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>Calculate vSphere 5 Licenses with Powershell (UPDATED)</title>
		<link>http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 09:41:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[Licensing]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=484</guid>
		<description><![CDATA[VMware has announced the next generation of vSphere yesterday. Besides lots of new features, vSphere 5 also comes with a new licensing structure. For every licensed physical CPU, you get a certain amount of vRAM, which you will be able to allocate to virtual machine. Only the running VM&#8217;s will count towards your license limit. <a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-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>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vmware.com/" target='_blank'>VMware</a> has announced the next generation of <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> yesterday. Besides lots of new features, <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> 5 also comes with a new licensing structure. For every licensed physical CPU, you get a certain amount of vRAM, which you will be able to allocate to virtual machine. Only the running VM&#8217;s will count towards your license limit.<br />
Curious how the <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> 5 licensing model will impact your license cost? Want to know how many <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> 5 liceses you will need? The following script calculates exactly how many licenses you need for the different editions and how much overhead you will have left.</p>
<p>UPDATE 04-AUG-2011: <a href="http://www.vmware.com/" target='_blank'>vmware</a> has increased vRAM entitlements for all editions of <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> 5! I have updated the script (shown below and the attached script). The screenshot is still the old one. Please read the <a href="http://www.vmware.com/files/pdf/vsphere_pricing.pdf" target="_blank">new Licensing PDF here</a> for all the details.</p>
<p>NOTE: Please note that I add up all your pCpu’s, ignoring current license types. I also add up all your current vRAM usage (RAM assigned to powered on VM’s). I then show you different scenarios if you purchase license type x for ALL your pCpu’s. If your environment consists of a mix of <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> editions, check out <a href="http://www.virtu-al.net/2011/08/03/vsphere-5-license-entitlement-changes/" target="_blank">Alan Renouf&#8217;s script</a> to analyse your environment.</p>
<p><a href="http://www.peetersonline.nl/wp-content/Vsp5.jpg"><img src="http://www.peetersonline.nl/wp-content/Vsp5.jpg" alt="" title="Vsp5" width="767" height="209" class="alignnone size-full wp-image-489" /></a><br />
 <span id="more-484"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$vCenterServerName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;MyVC1.domain.local&quot;</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;myVC2.domain.local&quot;</span> <span style="color: #008000;"># Enter your vCenter server name here. In case of multiple vCenter servers, separate using a comma.</span>
&nbsp;
<span style="color: #000080;">$ErrorActionPreference</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Stop&quot;</span>
&nbsp;
<span style="color: #008000;"># Connect to vCenter(s)</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Connecting...&quot;</span>
<span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$vCenterServerName</span>
&nbsp;
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Counting physical cpu's and vRAM in your environment. Please be patient...&quot;</span>
<span style="color: #008000;"># Gather information</span>
<span style="color: #800080;">$pCpu</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> <span style="color: #008080; font-style: italic;">-ExpandProperty</span> Hardware <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> <span style="color: #008080; font-style: italic;">-ExpandProperty</span> CpuInfo <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> NumCpuPackages <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.Sum
<span style="color: #800080;">$vRAM</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: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VM <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.PowerState <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;PoweredOn&quot;</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> MemoryMB <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.Sum<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">,</span><span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;======&quot;</span>
<span style="color: #800000;">&quot;pCpu Count: {0}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$pCpu</span>
<span style="color: #800000;">&quot;vRAM (GB):  {0}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$vRAM</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;======&quot;</span>
<span style="color: #008000;"># Disconnect</span>
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$vCenterServerName</span> <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$false</span>
&nbsp;
<span style="color: #008000;"># Calculate required licenses</span>
<span style="color: #800080;">$licCol</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$licObj</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> Edition<span style="color: pink;">,</span> Entitlement<span style="color: pink;">,</span> Licenses
<span style="color: #800080;">$licObj</span>.Edition <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Essentials/Essentials Plus/Standard&quot;</span>
<span style="color: #800080;">$licObj</span>.Entitlement <span style="color: pink;">=</span> <span style="color: #800000;">&quot;1 pCpu + 32 GB vRAM&quot;</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">32</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$licObj</span>.Licenses <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0} with {1} pCpu overhead&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Ceiling<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">32</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Ceiling<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">32</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">Else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$licObj</span>.Licenses <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0} with {1} GB vRAM overhead&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$pCpu</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #804000;">32</span> <span style="color: pink;">*</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$vRAM</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$licCol</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$licObj</span>
<span style="color: #800080;">$licObj</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> Edition<span style="color: pink;">,</span> Entitlement<span style="color: pink;">,</span> Licenses
<span style="color: #800080;">$licObj</span>.Edition <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Enterprise&quot;</span>
<span style="color: #800080;">$licObj</span>.Entitlement <span style="color: pink;">=</span> <span style="color: #800000;">&quot;1 pCpu + 64 GB vRAM&quot;</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">64</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$licObj</span>.Licenses <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0} with {1} pCpu overhead&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Ceiling<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">64</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Ceiling<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">64</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">Else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$licObj</span>.Licenses <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0} with {1} GB vRAM overhead&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$pCpu</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #804000;">64</span> <span style="color: pink;">*</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$vRAM</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$licCol</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$licObj</span>
<span style="color: #800080;">$licObj</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> Edition<span style="color: pink;">,</span> Entitlement<span style="color: pink;">,</span> Licenses
<span style="color: #800080;">$licObj</span>.Edition <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Enterprise Plus&quot;</span>
<span style="color: #800080;">$licObj</span>.Entitlement <span style="color: pink;">=</span> <span style="color: #800000;">&quot;1 pCpu + 96 GB vRAM&quot;</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">96</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$licObj</span>.Licenses <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0} with {1} pCpu overhead&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Ceiling<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">96</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Ceiling<span style="color: #000000;">&#40;</span><span style="color: #800080;">$vRAM</span><span style="color: pink;">/</span><span style="color: #804000;">96</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">Else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$licObj</span>.Licenses <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0} with {1} GB vRAM overhead&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$pCpu</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #804000;">96</span> <span style="color: pink;">*</span> <span style="color: #800080;">$pCpu</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">-</span> <span style="color: #800080;">$vRAM</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$licCol</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$licObj</span>
<span style="color: #008000;"># Displaying output</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Resulting license options:&quot;</span>
<span style="color: #800080;">$licCol</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;NOTE: vRAM only counts memory allocated to vm's that are POWERED ON.&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Red 
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;NOTE: Please double check the results of this script, since hosts may have been omitted due to errors.&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Red 
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Disclaimer: No rights can be deduced from this calculation.&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Red
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;======&quot;</span></pre></div></div>

<p>You can download the script here (rename to .ps1): <a href='http://www.peetersonline.nl/wp-content/Get-vSphere5LicensesUpdated.txt'>Get-vSphere5LicensesUpdated</a></p>
<p>Don’t forget to use <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> to run the script, or add the <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> snapin to your <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> session (Add-PSSnapIn <a href="http://www.vmware.com/" target='_blank'>vmware</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>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>Remove vmware memory limits with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 09:21:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Limits]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=477</guid>
		<description><![CDATA[Using Memory Limits in vmware vSphere can cause severe performance issues. The guest operating system assumes it can use all of the allocated memory, but vSphere will make sure the vm cannot use more than the memory limit. It does this by inflating a memory balloon using the balloon driver included with the vmware tools. <a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-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>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Using Memory Limits in <a href="http://www.vmware.com/" target='_blank'>vmware</a> <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> can cause severe performance issues. The guest operating system assumes it can use all of the allocated memory, but <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> will make sure the vm cannot use more than the memory limit. It does this by inflating a memory balloon using the balloon driver included with the <a href="http://www.vmware.com/" target='_blank'>vmware</a> tools. The performance chart in the <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> Client will show the virtual machine is ballooning. I never recommend using memory limits in <a href="http://www.vmware.com/" target='_blank'>vmware</a>.<br />
The following script will remove all memory limits in your <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> infrastructure, preventing the problems described above.<span id="more-477"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$vCenterServer</span> <span style="color: pink;">=</span> MyvCenterServer.domain.local <span style="color: #008000;">#Enter your vCenter server FQDN here</span>
&nbsp;
<span style="color: #008000;">#Connect to vCenter Server</span>
<span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$vCenterServer</span>
&nbsp;
<span style="color: #008000;">#Gathering data</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> get<span style="color: pink;">-</span>vm<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
&nbsp;
	<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;VM: $($vm.Name)&quot;</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Current Limit: $($vmView.config.MemoryAllocation.Limit)&quot;</span>
&nbsp;
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmView</span>.config.MemoryAllocation.Limit <span style="color: #FF0000;">-ne</span> <span style="color: pink;">-</span><span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;">#Preparing modified data</span>
		<span style="color: #800080;">$spec</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineConfigSpec
		<span style="color: #800080;">$MemoryAllocation</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.ResourceAllocationInfo
		<span style="color: #800080;">$MemoryAllocation</span>.Limit <span style="color: pink;">=</span> <span style="color: pink;">-</span><span style="color: #804000;">1</span>
		<span style="color: #800080;">$spec</span>.MemoryAllocation <span style="color: pink;">=</span> <span style="color: #800080;">$MemoryAllocation</span>
&nbsp;
		<span style="color: #008000;">#Applying modification</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Removing Memory Limit&quot;</span>
		<span style="color: #800080;">$vmView</span>.ReconfigVM<span style="color: #000000;">&#40;</span><span style="color: #800080;">$spec</span><span style="color: #000000;">&#41;</span>
&nbsp;
		<span style="color: #008000;">#Reloading data</span>
		<span style="color: #800080;">$vm</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>vm <span style="color: #800080;">$vm</span>.name
		<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: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Current Limit: $($vmView.config.MemoryAllocation.Limit)&quot;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #008000;">#Cleanup</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>
&nbsp;
<span style="color: #008000;">#Disconnect</span>
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$vCenterServer</span> <span style="color: #008080; font-style: italic;">-Confirm</span>:$false</pre></div></div>

<p>You can download the script here (rename to .ps1): <a href='http://www.peetersonline.nl/wp-content/Remove-MemoryLimits.txt'>Remove-MemoryLimits</a></p>
<p>Don&#8217;t forget to use <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> to run the script, or add the <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> snapin to your <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target='_blank'>Powershell</a> session (Add-PSSnapIn <a href="http://www.vmware.com/" target='_blank'>vmware</a>*).</p>
<p>Enjoy!</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>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Configure Syslog on Local Datastore with PowerCLI</title>
		<link>http://www.peetersonline.nl/index.php/powershell/configure-syslog-on-local-datastore-with-powercli/</link>
		<comments>http://www.peetersonline.nl/index.php/powershell/configure-syslog-on-local-datastore-with-powercli/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 13:13:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[syslog]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=471</guid>
		<description><![CDATA[Configuring a syslog folder is convenient for troubleshooting ESXi. But it&#8217;s a pain you-know-where to configure manually across all your ESXi servers. Luckily, PowerCLI can help out. This script creates a folder on the local datastore and configures ESXi to write the syslog in that folder. Enjoy! Hugo #Folder name you like $syslogFolderName = &#34;syslog&#34; <a href='http://www.peetersonline.nl/index.php/powershell/configure-syslog-on-local-datastore-with-powercli/'>[...]</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>Configuring a syslog folder is convenient for troubleshooting ESXi. But it&#8217;s a pain you-know-where to configure manually across all your ESXi servers. Luckily, <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> can help out. This script creates a folder on the local datastore and configures ESXi to write the syslog in that folder.<br />
Enjoy!<br />
Hugo<br />
<span id="more-471"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#Folder name you like</span>
<span style="color: #800080;">$syslogFolderName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;syslog&quot;</span>
&nbsp;
<span style="color: #008000;">#Connect to vCenter</span>
Connect<span style="color: pink;">-</span>VIServer vcenter.domain.local
&nbsp;
<span style="color: #008000;">#Loop through hosts</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> Get<span style="color: pink;">-</span>VMHost<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;">#Get only the first part of the FQDN (only if you used the FQDN to add the ESX server to vCenter)</span>
	<span style="color: #800080;">$hostname</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmhost</span>.name.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.ToUpper<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;">#Local datastore name (equal to hostname in my case)</span>
	<span style="color: #800080;">$datastorename</span> <span style="color: pink;">=</span> <span style="color: #800080;">$hostname</span>
&nbsp;
	<span style="color: #008000;">#Make the local datastore accessible as a PSdrive</span>
	<span style="color: #008080; font-weight: bold;">New-PSDrive</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$hostname</span> <span style="color: #008080; font-style: italic;">-Root</span> \ <span style="color: #008080; font-style: italic;">-PSProvider</span> VimDatastore <span style="color: pink;">-</span>Datastore <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Datastore <span style="color: #800080;">$datastorename</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">-Scope</span> global
&nbsp;
	<span style="color: #008000;">#Access the new PSDrive</span>
	<span style="color: #008080; font-weight: bold;">Set-Location</span> $hostname<span style="color: #800000;">&quot;:&quot;</span>
&nbsp;
	<span style="color: #008000;">#Create the syslog folder</span>
	<span style="color: #008080; font-weight: bold;">New-Item</span> <span style="color: #800080;">$syslogFolderName</span> <span style="color: #008080; font-style: italic;">-ItemType</span> directory
&nbsp;
	<span style="color: #008000;">#Set the advanced parameter to configure the syslog on the local datastore</span>
	<span style="color: #800080;">$value</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;[$datastorename] $syslogFoldername/$hostname.log&quot;</span>
	Set<span style="color: pink;">-</span>VMHostAdvancedConfiguration <span style="color: pink;">-</span>VMHost <span style="color: #800080;">$vmhost</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;Syslog.Local.DatastorePath&quot;</span> <span style="color: #008080; font-style: italic;">-Value</span> <span style="color: #800080;">$value</span>
&nbsp;
	<span style="color: #008000;">#Cleanup</span>
	<span style="color: #008080; font-weight: bold;">Set-Location</span> <span style="color: #800080;">$PSHOME</span>
	<span style="color: #008080; font-weight: bold;">Remove-PSDrive</span> <span style="color: #800080;">$hostname</span>
	<span style="color: #008080; font-weight: bold;">Clear-Variable</span> hostname <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
	<span style="color: #008080; font-weight: bold;">Clear-Variable</span> datastorename <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
	<span style="color: #008080; font-weight: bold;">Clear-Variable</span> value <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;">#Disconnect from vCenter</span>
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #008080; font-style: italic;">-confirm</span>:$false</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/powershell/configure-syslog-on-local-datastore-with-powercli/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Set vApp Guest Shutdown</title>
		<link>http://www.peetersonline.nl/index.php/vmware/set-vapp-guest-shutdown/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/set-vapp-guest-shutdown/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 07:28:17 +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[Shutdown]]></category>
		<category><![CDATA[vApp]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=462</guid>
		<description><![CDATA[Annoyed by the default setting for VM&#8217;s inside a vApp? I was, because when you power down the vApp, the VM&#8217;s are powered down instead of being shutdown cleanly. It can be a tedious task to check and correct this setting for all your vApps. This little script solves that problem for you. Enjoy! $VC <a href='http://www.peetersonline.nl/index.php/vmware/set-vapp-guest-shutdown/'>[...]</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>Annoyed by the default setting for VM&#8217;s inside a vApp? I was, because when you power down the vApp, the VM&#8217;s are powered down instead of being shutdown cleanly. It can be a tedious task to check and correct this setting for all your vApps. This little script solves that problem for you. Enjoy!</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;MyvCenter.local&quot;</span>
&nbsp;
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Vapp</span> <span style="color: #0000FF;">in</span> Get<span style="color: pink;">-</span>VApp<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>	
	<span style="color: #800080;">$VAppView</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VApp</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;">$Entity</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$VAppView</span>.VAppConfig.EntityConfig<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Entity</span>.StopAction <span style="color: #FF0000;">-ne</span> <span style="color: #800000;">&quot;guestShutdown&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$VAppConfigSpec</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VAppConfigSpec
		<span style="color: #800080;">$EntityConfig</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VAppEntityConfigInfo
			<span style="color: #800080;">$EntityConfig</span>.Key <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>View <span style="color: #800080;">$Entity</span>.Key<span style="color: #000000;">&#41;</span>.MoRef
			<span style="color: #800080;">$EntityConfig</span>.StopAction <span style="color: pink;">=</span> <span style="color: #800000;">&quot;guestShutdown&quot;</span>
		<span style="color: #800080;">$VAppConfigSpec</span>.EntityConfig <span style="color: pink;">=</span> <span style="color: #800080;">$EntityConfig</span>
&nbsp;
		<span style="color: #800080;">$VAppView</span>.UpdateVAppConfig<span style="color: #000000;">&#40;</span><span style="color: #800080;">$VAppConfigSpec</span><span style="color: #000000;">&#41;</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>Download script: <a href='http://www.peetersonline.nl/wp-content/Set-VAppGuestShutdown.txt'>Set-VAppGuestShutdown (rename to .ps1)</a></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/set-vapp-guest-shutdown/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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 <a href='http://www.peetersonline.nl/index.php/vmware/set-vmware-snapshot-location-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>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: #0000FF;">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>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/set-vmware-snapshot-location-with-powershell/feed/</wfw:commentRss>
		<slash:comments>12</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 <a href='http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-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>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>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/create-a-vswitch-port-overview-with-powershell/feed/</wfw:commentRss>
		<slash:comments>2</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; Related posts: Calculate vSphere 5 Licenses with Powershell (UPDATED) Remove vmware memory limits with Powershell
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>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>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/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 <a href='http://www.peetersonline.nl/index.php/vmware/translate-vml-to-lun-path-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>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: #804000;">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>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/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 $_}} Related posts: Remove vmware memory limits with Powershell Calculate vSphere 5 Licenses with Powershell (UPDATED)
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>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>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/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 <a href='http://www.peetersonline.nl/index.php/vmware/vi-toolkit-15-getting-started-and-undocumented-functions/'>[...]</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><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>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/vi-toolkit-15-getting-started-and-undocumented-functions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

