<?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; VI Toolkit 1.5</title>
	<atom:link href="http://www.peetersonline.nl/index.php/category/vmware/vi-toolkit-15/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>Report vSphere Alarms with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/report-vsphere-alarms-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/report-vsphere-alarms-with-powershell/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 10:58:15 +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[Alarms]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=418</guid>
		<description><![CDATA[Wow, vSphere vCenter Server has a lot of new alarms! Great for monitoring your environment. But a pain when it comes to documenting it. Thank God VMware for the PowerCLI! Just a few lines of code can do the documentation for you. Here&#8217;s how: # Report vSphere Alarms # by Hugo Peeters # www.peetersonline.nl &#160; <a href='http://www.peetersonline.nl/index.php/vmware/report-vsphere-alarms-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>Wow, <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> vCenter Server has a lot of new alarms! Great for monitoring your environment. But a pain when it comes to documenting it. Thank <del datetime="2009-10-30T10:54:17+00:00">God</del> <a href="http://www.vmware.com/" target='_blank'>VMware</a> for the <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a>! Just a few lines of code can do the documentation for you.</p>
<p>Here&#8217;s how:</p>
<p><span id="more-418"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Report vSphere Alarms</span>
<span style="color: #008000;"># by Hugo Peeters</span>
<span style="color: #008000;"># www.peetersonline.nl</span>
&nbsp;
<span style="color: #008000;">#Region Variables</span>
<span style="color: #800080;">$VCServer</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;myVCServer&quot;</span>
<span style="color: #800080;">$Outfile</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;D:\scripts\Alarms.txt&quot;</span>
&nbsp;
Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$VCServer</span>
<span style="color: #800080;">$SI</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View ServiceInstance
<span style="color: #800080;">$AM</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #800080;">$SI</span>.Content.AlarmManager
<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;">$Folder</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Folder<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;">$Alarm</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$AM</span>.GetAlarm<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Folder</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>View<span style="color: #000000;">&#41;</span>.MoRef<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Alarm</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #800080;">$Alarm</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> Folder<span style="color: pink;">,</span> Name<span style="color: pink;">,</span> Description<span style="color: pink;">,</span> Enabled<span style="color: pink;">,</span> Summary
		<span style="color: #800080;">$myObj</span>.Folder <span style="color: pink;">=</span> <span style="color: #800080;">$Folder</span>.Name
		<span style="color: #800080;">$myObj</span>.Name <span style="color: pink;">=</span> <span style="color: #800080;">$Alarm</span>.Info.Name
		<span style="color: #800080;">$myObj</span>.Description <span style="color: pink;">=</span> <span style="color: #800080;">$Alarm</span>.Info.Description
		<span style="color: #800080;">$myObj</span>.Enabled <span style="color: pink;">=</span> <span style="color: #800080;">$Alarm</span>.Info.Enabled
		<span style="color: #800080;">$myObj</span>.Summary <span style="color: pink;">=</span> <span style="color: #800080;">$Alarm</span>.Info.Expression.Expression <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-String</span>
		<span style="color: #800080;">$myObj</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: #000000;">&#125;</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Enabled<span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #800080;">$Outfile</span>
<span style="color: #008080; font-weight: bold;">ii</span> $Outfile</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/report-vsphere-alarms-with-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Add Vmx Path to VI Client using Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/add-vmx-path-to-vi-client-using-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/add-vmx-path-to-vi-client-using-powershell/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 08:56:41 +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[Custom Fields]]></category>
		<category><![CDATA[vSphere Client]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=415</guid>
		<description><![CDATA[The following script is a request from David Gontie, who was kind enough to comment on a previous post. He&#8217;d like to add the location of his vm&#8217;s to a custom field. This is especially handy if you store all the files for a vm in a single datastore. Here you go David: ############################## # Script <a href='http://www.peetersonline.nl/index.php/vmware/add-vmx-path-to-vi-client-using-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>The following script is a request from David Gontie, who was kind enough to comment on a previous post.</p>
<p>He&#8217;d like to add the location of his vm&#8217;s to a custom field. This is especially handy if you store all the files for a vm in a single datastore.</p>
<p>Here you go David:</p>
<p><span id="more-415"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">##############################</span>
<span style="color: #008000;"># Script created by Hugo Peeters #</span>
<span style="color: #008000;"># http://www.peetersonline.nl   #</span>
<span style="color: #008000;">##############################</span>
&nbsp;
<span style="color: #008000;"># Variables</span>
<span style="color: #800080;">$VCServerName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;MYVCSERVER&quot;</span>
<span style="color: #800080;">$CustomFieldName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;VMX&quot;</span>
<span style="color: #800080;">$ManagedObjectType</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;VirtualMachine&quot;</span>
&nbsp;
<span style="color: #008000;"># Script</span>
<span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$VCServerName</span>
<span style="color: #800080;">$SI</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View ServiceInstance
<span style="color: #800080;">$CFM</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #800080;">$SI</span>.Content.CustomFieldsManager
&nbsp;
<span style="color: #800080;">$myCustomField</span> <span style="color: pink;">=</span> <span style="color: #800080;">$CFM</span>.Field <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$CustomFieldName</span><span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$myCustomField</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Create Custom Field</span>
	<span style="color: #800080;">$FieldCopy</span> <span style="color: pink;">=</span> <span style="color: #800080;">$CFM</span>.Field<span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>
	<span style="color: #800080;">$CFM</span>.AddCustomFieldDef<span style="color: #000000;">&#40;</span><span style="color: #800080;">$CustomFieldName</span><span style="color: pink;">,</span><span style="color: #800080;">$ManagedObjectType</span><span style="color: pink;">,</span><span style="color: #800080;">$FieldCopy</span>.FieldDefPrivileges<span style="color: pink;">,</span><span style="color: #800080;">$FieldCopy</span>.FieldInstancePrivileges<span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$myCustomField</span> <span style="color: pink;">=</span> <span style="color: #800080;">$CFM</span>.Field <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Name <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$CustomFieldName</span><span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Fill Custom Fields</span>
<span style="color: #800080;">$VMs</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VM
<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: #800080;">$VMs</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: #800080;">$VMXPath</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VMView</span>.Config.Files.VMPathName
	<span style="color: #008000;"># Compare value to current value</span>
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMXPath</span> <span style="color: #FF0000;">-ne</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMView</span>.CustomValue <span style="color: pink;">|</span> <span style="color: pink;">?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Key <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$myCustomField</span>.Key<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.Value<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># Set Custom Value</span>
		<span style="color: #800080;">$VMView</span>.setCustomValue<span style="color: #000000;">&#40;</span><span style="color: #800080;">$CustomFieldName</span><span style="color: pink;">,</span><span style="color: #800080;">$VMXPath</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #008080; font-weight: bold;">Clear-Variable</span> VMXPath <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
	<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>
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/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/add-vmx-path-to-vi-client-using-powershell/feed/</wfw:commentRss>
		<slash:comments>11</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>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>

