<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:clearspace="http://www.jivesoftware.com/xmlns/clearspace/rss" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>VMware Communities : Document List - VMware vSphere™ PowerCLI</title>
    <link>http://communities.vmware.com/community/vmtn/vsphere/automationtools/windows_toolkit?view=documents</link>
    <description>Latest Documents in VMware vSphere™ PowerCLI</description>
    <language>en</language>
    <pubDate>Fri, 20 Nov 2009 09:01:55 GMT</pubDate>
    <generator>Clearspace 1.10.12 (http://jivesoftware.com/products/clearspace/)</generator>
    <dc:date>2009-11-20T09:01:55Z</dc:date>
    <dc:language>en</dc:language>
    <item>
      <title>vSphere PowerCLI 4.0 Update 1 Cmdlet Reference</title>
      <link>http://communities.vmware.com/docs/DOC-11350</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">vitoolkit</category>
      <pubDate>Fri, 20 Nov 2009 08:59:10 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-11350</guid>
      <dc:date>2009-11-20T08:59:10Z</dc:date>
      <clearspace:dateToText>3 days, 15 hours ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>ESX Install Kit</title>
      <link>http://communities.vmware.com/docs/DOC-10814</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vm</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vmware</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vitoolkit</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powercli</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">toolkit</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vi_toolkit_windows</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">esx</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">esxi</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">deployment</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">factory</category>
      <pubDate>Thu, 24 Sep 2009 13:42:26 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-10814</guid>
      <dc:date>2009-09-24T13:42:26Z</dc:date>
      <clearspace:dateToText>1 week, 1 day ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>Using VI Toolkit from .Net C#</title>
      <link>http://communities.vmware.com/docs/DOC-10631</link>
      <description>&lt;a class="jive-link-external" href="http://www.slideshare.net/vmwarecarter/using-vi-toolkit-for-windows-from-net#"&gt;http://www.slideshare.net/vmwarecarter/using-vi-toolkit-for-windows-from-net#&lt;/a&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vi</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">toolkit</category>
      <pubDate>Fri, 28 Aug 2009 05:44:54 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-10631</guid>
      <dc:date>2009-08-28T05:44:54Z</dc:date>
      <clearspace:dateToText>2 months, 3 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Check for Privileges</title>
      <link>http://communities.vmware.com/docs/DOC-10607</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">powercli</category>
      <pubDate>Wed, 26 Aug 2009 03:14:42 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-10607</guid>
      <dc:date>2009-08-26T03:14:42Z</dc:date>
      <clearspace:dateToText>2 months, 4 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Quick Migrate Function</title>
      <link>http://communities.vmware.com/docs/DOC-10441</link>
      <description>&lt;h2&gt;VMWare Quick Migration Function&lt;/h2&gt;
&lt;br /&gt;
&lt;b&gt;Author&lt;/b&gt;: Justin Grote &amp;lt;jgrote NOSPAMAT enpointe DOT com&amp;gt;&lt;br /&gt;
&lt;b&gt;Credit&lt;/b&gt;: Inspired by Mike DiPetrillo's Quick Migration Script: &lt;a class="jive-link-external" href="http://www.mikedipetrillo.com/mikedvirtualization/2008/10/quick-migration-for-vmware-the-power-of-powershell.html"&gt;http://www.mikedipetrillo.com/mikedvirtualization/2008/10/quick-migration-for-vmware-the-power-of-powershell.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;Version&lt;/b&gt;: 0.1&lt;br /&gt;
&lt;b&gt;Last Revised&lt;/b&gt;: 31 July 2009&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Description&lt;/b&gt;: Performs the fucntional equivalent of a Hyper-V Quick Migration by suspending a VM, &lt;br /&gt;
 moving it to a new host, and resuming it. This does not require vMotion licensing.&lt;br /&gt;
 it works by providing required VM objects via the pipeline or the second argument, &lt;br /&gt;
 and specifying the Destination host in the first argument.&lt;br /&gt;
 The commeand accepts both text strings and VMHost objects for the VMHost Parameter&lt;br /&gt;
&lt;p /&gt;
&lt;b&gt;Prerequisites&lt;/b&gt;:&lt;br /&gt;
Powershell v1&lt;br /&gt;
VMWare PowerCLI 4.0 (May work with earlier version but not tested)&lt;br /&gt;
&lt;br /&gt;
Instructions to Install: Save this script and import into your session with, for example, . C:\temp\quickmigrate.ps1&lt;br /&gt;
You can also include it in your PowerCLI profile to have it automatically included.&lt;br /&gt;
&lt;p /&gt;
&lt;b&gt;Command Usage&lt;/b&gt;: get-vm MyTestVM | Quick-MigrateVM "MyTestHost2"</description>
      <pubDate>Fri, 31 Jul 2009 19:43:20 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-10441</guid>
      <dc:date>2009-07-31T19:43:20Z</dc:date>
      <clearspace:dateToText>3 months, 3 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Get-Stat2 : another way of getting at the statistical data</title>
      <link>http://communities.vmware.com/docs/DOC-10384</link>
      <description>With the release of PowerCLI v4 the &lt;b&gt;Get-Stat&lt;/b&gt; cmdlet has been much improved.&lt;br /&gt;
&lt;br /&gt;
In October 2008, as a temporary solution for the problems with the Get-Stat cmdlet in older PowerCLI or VITK releases, I wrote the Get-Stat2 script.&lt;br /&gt;
The Get-Stat2 script allows lightly different parameters than the regular Get-Stat cmdlet.&lt;br /&gt;
&lt;br /&gt;
For that reason I will make the Get-Stat2 script available again (the original document was removed some time ago).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;But please only use this script when you couldn't get the result you needed with the current Get-Stat cmdlet!&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;An extract from the original document:&lt;/i&gt;&lt;br /&gt;
The script accepts the following parameters:&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;-Entity &amp;lt;VIObject&amp;gt;	: the object for which the statiscal data will be collected. Only 1 object allowed !
-Start &amp;lt;DateTime&amp;gt;	: start of the interval
-Finish &amp;lt;DateTime&amp;gt;	: end of the interval
-Stat &amp;lt;string[]&amp;gt;	: array of statistic identifiers
-Instance &amp;lt;string&amp;gt;	: some statistic identifiers allow instances.
                        (&amp;quot;&amp;quot; : aggregate (default) / &amp;quot;*&amp;quot; : all instances / array of specific instances)
-Interval &amp;lt;string&amp;gt;	: desired sampling interval, allowed values: &amp;quot;RT&amp;quot;,&amp;quot;HI1&amp;quot;,&amp;quot;HI2&amp;quot;,&amp;quot;HI3&amp;quot;,&amp;quot;HI4&amp;quot;
			  RT : real time
                          HI : historical interval
                         (results in these defaults 20, 300, 1800, 7200, 86400 seconds)
-Maxsamples &amp;lt;int32&amp;gt;	: only for &amp;quot;Real time&amp;quot; interval; number of intervals
-QueryMetrics		: return all available metrics for the Entity
-QueryInstances	: return all available instances for the Entity and Stat
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Update 01/11/08&lt;/u&gt;&lt;br /&gt;
When you add a new resource to an entity, the statistical data for historical intervals will not be available immediately.&lt;br /&gt;
You will have to wait at least till the sampling period of the historical interval has expired.&lt;br /&gt;
The QueryPerf method will return sampling periods (date/time stamps) but there will be no statistical data (yet).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;you add a vCPU to a virtual machine&lt;/li&gt;
&lt;li&gt;data for HI2 for that CPU instance will only be available after +/- 30 minutes&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The minimum wait time to see data for a new resource:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;RT     20 secs&lt;/li&gt;
&lt;li&gt;HI1    5 mins&lt;/li&gt;
&lt;li&gt;HI2    30 mins&lt;/li&gt;
&lt;li&gt;HI3    2 hours&lt;/li&gt;
&lt;li&gt;HI4    1 day&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
To avoid errors from the Get-Stat2 function a test was added to verify if any data was returned by the QueryPerf method.&lt;br /&gt;
If there is no data, the Get-Stat2 function returns $null.&lt;br /&gt;
&lt;br /&gt;
The attached script has been updated.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Update 15/02/09&lt;/u&gt;&lt;br /&gt;
The attached Get-Stat2.ps1 script has been updated.&lt;br /&gt;
The changes:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;corrected MaxSamples parameter&lt;/li&gt;
&lt;li&gt;corrected Cluster entity clastype&lt;/li&gt;
&lt;li&gt;corrected missing Start and Finish parameters test&lt;/li&gt;
&lt;li&gt;added -QueryMetrics option&lt;/li&gt;
&lt;li&gt;added -QueryInstances option&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
With the addition of these last two parameters, the script can now be used to&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;query all the &lt;b&gt;valid metrics&lt;/b&gt; for a specific entity&lt;/li&gt;
&lt;li&gt;query all the &lt;b&gt;valid instances&lt;/b&gt; for one or more metrics&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;u&gt;Example -QueryMetrics&lt;/u&gt;&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;
$esx = Get-VMHost &amp;lt;ESX-hostname&amp;gt; | Get-View
./Get-Stat2.ps1 -entity $esx -querymetrics |ft

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
produces an array of custom objects like this&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;
Group                Name                               Rollup                  Id               Level                Type Unit
-----                ----                               ------                  --               -----                ---- ----
clusterServices      cpufairness                        latest                 105                   1            absolute number
clusterServices      memfairness                        latest                 106                   1            absolute number
cpu                  idle                            summation                 112                   3               delta millisecond
cpu                  reservedCapacity                  average                 110                   2            absolute megaHertz
cpu                  usage                             average                   2                   1                rate percent
cpu                  usage                             maximum                   4                   4                rate percent
cpu                  usage                             minimum                   3                   4                rate percent
cpu                  usagemhz                          average                   6                   1                rate megaHertz
cpu                  usagemhz                          maximum                   8                   4                rate megaHertz
cpu                  usagemhz                          minimum                   7                   4                rate megaHertz
cpu                  used                            summation                 111                   3               delta millisecond
disk                 busResets                       summation                 115                   3               delta number
disk                 commands                        summation                 113                   3               delta number
disk                 commandsAborted                 summation                 114                   3               delta number
disk                 deviceLatency                     average                 156                   2            absolute millisecond
disk                 deviceReadLatency                 average                 148                   2            absolute millisecond
disk                 deviceWriteLatency                average                 152                   2            absolute millisecond
disk                 kernelLatency                     average                 157                   2            absolute millisecond
disk                 kernelReadLatency                 average                 149                   2            absolute millisecond
disk                 kernelWriteLatency                average                 153                   2            absolute millisecond
disk                 numberRead                      summation                  91                   3               delta number
disk                 numberWrite                     summation                  92                   3               delta number
disk                 queueLatency                      average                 159                   2            absolute millisecond
disk                 queueReadLatency                  average                 151                   2            absolute millisecond
...

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;u&gt;Example QueryInstances&lt;/u&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;
$esx = Get-VMHost &amp;lt;ESX-hostname&amp;gt; | Get-View
./Get-Stat2-v1.1.ps1 -entity $esx -stat &amp;quot;disk.deviceLatency.average&amp;quot;,&amp;quot;net.received.average&amp;quot; -queryinstances | ft

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
produces an array of custom objects like this&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;
Stat                                                                    Instance
----                                                                    --------
disk.deviceLatency.average                                              vmhba0:0:0
disk.deviceLatency.average                                              vmhba0:1:0
disk.deviceLatency.average                                              vmhba32:0:0
disk.deviceLatency.average                                              vmhba32:0:1
disk.deviceLatency.average                                              vmhba32:1:0
disk.deviceLatency.average                                              vmhba32:11:0
disk.deviceLatency.average                                              vmhba32:2:0
disk.deviceLatency.average                                              vmhba32:2:1
disk.deviceLatency.average                                              vmhba32:6:0
disk.deviceLatency.average                                              vmhba32:6:1
disk.deviceLatency.average                                              vmhba32:7:0
disk.deviceLatency.average                                              vmhba32:7:1
disk.deviceLatency.average                                              vmhba32:8:0
net.received.average                                                    vmnic0
net.received.average                                                    vmnic1
net.received.average                                                    vmnic2
net.received.average                                                    vmnic3

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;b&gt;Note&lt;/b&gt; that an instance can have a length zero for some metrics.&lt;br /&gt;
This ("") is the instance that returns the aggregated statistics value.&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;
$esx = Get-VMHost &amp;lt;ESX-hostname&amp;gt; | Get-View
./Get-Stat2-v1.1.ps1 -entity $esx -stat &amp;quot;cpu.usage.average&amp;quot; -queryinstances | ft

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
returns&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;
Stat                                                                    Instance
----                                                                    --------
cpu.usage.average
cpu.usage.average                                                       0
cpu.usage.average                                                       1

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
The first object in the array is the "aggregate" instance.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Update 02/03/09&lt;/u&gt;&lt;br /&gt;
The attached Get-Stat2.ps1 script has been updated.&lt;br /&gt;
The changes:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;corrected issue with missing -Maxsamples parameter&lt;/li&gt;
&lt;li&gt;corrected issue with incorrect instances returned for -QueryInstances&lt;/li&gt;
&lt;li&gt;introduced default value ("RT") for -Interval parameter&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Tue, 21 Jul 2009 15:18:59 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-10384</guid>
      <dc:date>2009-07-21T15:18:59Z</dc:date>
      <clearspace:dateToText>4 months, 5 days ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>Issue getting healthcheck to run manually or scheduled</title>
      <link>http://communities.vmware.com/docs/DOC-10327</link>
      <description>&lt;br /&gt;
Up until ESX 3.5 Update 4 we had the HealthCheck script schedule to run everyday, but since we updated it does not seem to be able to run.&lt;br /&gt;
&lt;p /&gt;
I have tried it manually and recieved this error:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;a class="jive-link-adddocument" href="http://communities.vmware.com/community-document-picker.jspa?communityID=2530&amp;subject=vSphere+PowerCLI"&gt;vSphere PowerCLI&lt;/a&gt; C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts&amp;gt; dir &lt;br clear="all" /&gt; Directory: Microsoft.PowerShell.Core\FileSystem::C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts &lt;br clear="all" /&gt; Mode                LastWriteTime     Length Name &lt;br clear="all" /&gt; ----&lt;hr /&gt;&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;ul class="jive-dash"&gt;

&lt;ul class="jive-dash"&gt;

&lt;ul class="jive-dash"&gt;

&lt;ul class="jive-dash"&gt;
&lt;li&gt;&lt;br clear="all" /&gt; -a---          7/7/2009   2:12 PM      16674 Healthcheck.ps1 &lt;br clear="all" /&gt; -a---         4/23/2009   6:56 AM       7771 Initialize-VIToolkitEnvironment.ps1 &lt;br clear="all" /&gt; &lt;a class="jive-link-adddocument" href="http://communities.vmware.com/community-document-picker.jspa?communityID=2530&amp;subject=vSphere+PowerCLI"&gt;vSphere PowerCLI&lt;/a&gt; C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts&amp;gt; ./Healthcheck.ps1 &lt;br clear="all" /&gt; Incomplete string token. &lt;br clear="all" /&gt; At C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Healthcheck.ps1:121 char:270 &lt;br clear="all" /&gt; +     $vmhosts | Sort Name -Descending | % { $server = $_ |get-view; $server.Config.Product | select { $server.Name }, Version, Build, FullName }| Co &lt;br clear="all" /&gt; nvertTo-Html &amp;acirc;?"body "&amp;lt;H2&amp;gt;$cluster Cluster Information.&amp;lt;/H2&amp;gt;" -head "&amp;lt;link rel='stylesheet' href='style.css' type='text/css' / &amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;gt;" | Out-File -Ap &lt;br clear="all" /&gt; pend $filelocation &lt;br clear="all" /&gt; &lt;a class="jive-link-adddocument" href="http://communities.vmware.com/community-document-picker.jspa?communityID=2530&amp;subject=vSphere+PowerCLI"&gt;vSphere PowerCLI&lt;/a&gt; C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts&amp;gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
Any assistance would be greatly appreciated&lt;br /&gt;
&lt;br /&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vi_toolkit_windows</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">report</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">reporting</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">toolkit</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vi</category>
      <pubDate>Tue, 07 Jul 2009 19:38:23 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-10327</guid>
      <dc:date>2009-07-07T19:38:23Z</dc:date>
      <clearspace:dateToText>4 months, 2 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>3</clearspace:replyCount>
    </item>
    <item>
      <title>E-Mail Alert for Datastores</title>
      <link>http://communities.vmware.com/docs/DOC-9663</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">get-datastore</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">free</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">space</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">email</category>
      <pubDate>Mon, 09 Mar 2009 17:40:25 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9663</guid>
      <dc:date>2009-03-09T17:40:25Z</dc:date>
      <clearspace:dateToText>8 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Portgroup - how to configure Nic Teaming</title>
      <link>http://communities.vmware.com/docs/DOC-9564</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">portgroup</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">nic</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">teaming</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">sdk</category>
      <pubDate>Sun, 22 Feb 2009 01:48:00 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9564</guid>
      <dc:date>2009-02-22T01:48:00Z</dc:date>
      <clearspace:dateToText>9 months, 4 days ago</clearspace:dateToText>
    </item>
    <item>
      <title>list virtual machines per cluster</title>
      <link>http://communities.vmware.com/docs/DOC-9506</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$clusters = get-cluster

foreach ($cluster in $clusters)
{
    foreach ($vmhost in ($cluster | get-vmhost))
    {
        $vmhost | get-vm | Select-Object @{Name=&amp;quot;Cluster&amp;quot;; Expression={$cluster.name}},`
            Name
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;a href="http://www.vmwarescripting.com"&gt;http://www.vmwarescripting.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/192793" class="jive-link-thread"&gt;list virtual machines per cluster&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:32:32 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9506</guid>
      <dc:date>2009-02-10T14:32:32Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>Here is a PowerShell script to list datastore information per cluster</title>
      <link>http://communities.vmware.com/docs/DOC-9505</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$clusters = get-cluster
aforeach ($cluster in $clusters)
{
    $vmhosts = $cluster | get-vmhost
    $firsthost = $vmhosts[0]
    $datastores = $firsthost | get-datastore | % {(Get-View $_.ID).summary}
    foreach ($datastore in $datastores)
    {
        $datastore | select-object @{Name = &amp;quot;Date&amp;quot;; Expression = {get-date}}, @{Name = &amp;quot;Cluster&amp;quot;; Expression = {$cluster.name}}, URL, Name, Freespace, Capacity
           }
        }
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;a href="http://www.vmwarescripting.com"&gt;http://www.vmwarescripting.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/191835" class="jive-link-thread"&gt;Here is a PowerShell script to list datastore information per cluster&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:31:42 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9505</guid>
      <dc:date>2009-02-10T14:31:42Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>get the socket/core info for each vmware host</title>
      <link>http://communities.vmware.com/docs/DOC-9504</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;Get-VMHost | %{Get-View $_.ID} | %{
  $name = $_.name
  $esx = &amp;quot;&amp;quot; | select NumCpuPackages, NumCpuCores, Hz, Memory
  $esx.NumCpuPackages = $_.Hardware.CpuInfo.NumCpuPackages 
  $esx.NumCpuCores = $_.Hardware.CpuInfo.NumCpuCores
  $esx | select-object @{Name = &amp;quot;Name&amp;quot;; Expression = {$name}}, @{Name = &amp;quot;Sockets&amp;quot;; Expression = {$esx.NumCpuPackages}}, @{Name = &amp;quot;Cores&amp;quot;; Expression = {$esx.NumCpuCores}}
  }
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;br /&gt;
&lt;a href="http://www.vmwarescripting.com"&gt;http://www.vmwarescripting.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/192806" class="jive-link-thread"&gt;get the socket/core info for each vmware host&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:30:59 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9504</guid>
      <dc:date>2009-02-10T14:30:59Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Compare hostname of VM with display name of VM</title>
      <link>http://communities.vmware.com/docs/DOC-9503</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$VMs = Get-VM
foreach ($VM in $VMs){
	$VM = Get-View $VM.ID
	$nm = $VM.name
    $hn = $VM.guest.hostname 
    $vm | select @{Name = &amp;quot;Name&amp;quot;; Expression = {$nm}}, @{Name = &amp;quot;Hostname&amp;quot;; Expression = {$hn}}
    }
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.vmwarescripting.com"&gt;http://www.vmwarescripting.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/192811" class="jive-link-thread"&gt;Compare hostname of VM with display name of VM&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:30:36 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9503</guid>
      <dc:date>2009-02-10T14:30:36Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Find HA/DRS status of each host in cluster</title>
      <link>http://communities.vmware.com/docs/DOC-9502</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;Get-Cluster | Get-View | %{
  foreach($h in $_.Host){
      Write-Host $_.name
      Write-Host &amp;quot;`tDRS enabled : &amp;quot; $_.Configuration.DRSConfig.Enabled
      Write-Host &amp;quot;`tHA enabled  : &amp;quot; $_.Configuration.DasConfig.Enabled
    }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;a href="http://www.vmwarescripting.com"&gt;http://www.vmwarescripting.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/193571" class="jive-link-thread"&gt;Find HA/DRS status of each host in cluster&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:30:22 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9502</guid>
      <dc:date>2009-02-10T14:30:22Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>verify licensed features of a vmware host</title>
      <link>http://communities.vmware.com/docs/DOC-9501</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$vmhostname = &amp;quot;vmhostname.domain.com&amp;quot;
Connect-VIServer $vmhostname | Out-Null
$vmhost = get-vmhost
$ServiceInstance = Get-View ServiceInstance
$LicManRef=$ServiceInstance.Content.LicenseManager
$LicManView=Get-View $LicManRef
$LicManView.featureinfo | Where-Object {$_.state -eq &amp;quot;enabled&amp;quot;} | `
    Select-Object      @{Name = &amp;quot;VMHost&amp;quot;; Expression = {$vmhost.name}},`
                       @{Name = &amp;quot;License Server&amp;quot;; Expression = {$licManView.source.LicenseServer}},`
                       @{Name = &amp;quot;Version&amp;quot;; Expression = {$licManView.LicensedEdition}},`
                       @{Name = &amp;quot;Feature&amp;quot;; Expression = {$_.key}}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/193570" class="jive-link-thread"&gt;verify licensed features of a vmware host&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:29:35 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9501</guid>
      <dc:date>2009-02-10T14:29:35Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>find left over VCB snapshots</title>
      <link>http://communities.vmware.com/docs/DOC-9500</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;Get-VM | Get-Snapshot | `
    Where-Object {$_.Name -eq &amp;quot;_VCB-BACKUP_&amp;quot;} | `
	Select Name, @{Name=&amp;quot;VM Name&amp;quot; ; `
	Expression={$_.VM.Name}}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;a href="http://www.vmwarescripting.com"&gt;http://www.vmwarescripting.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This document was generated from the following thread:&amp;nbsp;&lt;a href="http://communities.vmware.com/thread/193569" class="jive-link-thread"&gt;find left over VCB snapshots&lt;/a&gt;</description>
      <pubDate>Tue, 10 Feb 2009 14:28:54 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9500</guid>
      <dc:date>2009-02-10T14:28:54Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Export/import baselines from one Update Manager server to another</title>
      <link>http://communities.vmware.com/docs/DOC-9471</link>
      <description />
      <pubDate>Mon, 09 Feb 2009 14:36:52 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9471</guid>
      <dc:date>2009-02-09T14:36:52Z</dc:date>
      <clearspace:dateToText>9 months, 2 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>12</clearspace:replyCount>
    </item>
    <item>
      <title>set-vi3-entity switch code for scripts</title>
      <link>http://communities.vmware.com/docs/DOC-9425</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">vitoolkit</category>
      <pubDate>Wed, 04 Feb 2009 20:38:15 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9425</guid>
      <dc:date>2009-02-04T20:38:15Z</dc:date>
      <clearspace:dateToText>9 months, 3 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Live Cloning with Powershell - Across Clusters/Hosts</title>
      <link>http://communities.vmware.com/docs/DOC-9422</link>
      <description>&lt;b&gt;I have written a script that will clone a live vm from one cluster to another (Across Datacenters or Local).&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;To understand what is happeing I will explain our environment and then what this is used for:&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;b&gt;Environment:&lt;/b&gt; &lt;br clear="all" /&gt;	Consists of 3 Clusters spanning 2 DataCenters (2 in NYC, 1 in NJ) &lt;br clear="all" /&gt;	All Managed by a single VirtualCenter Server(VM) &lt;br clear="all" /&gt;	All ESX Hosts are HP BL680c G5 fully Loaded and are attached to HP EVA 8K's with multiple Fiber Connection/Paths. &lt;br clear="all" /&gt;	All Network connections are aggregated for maximum bandwith (Minimum 4 connection per VLAN). &lt;br clear="all" /&gt;&lt;b&gt;So now what the scripts are used for:&lt;/b&gt; &lt;br clear="all" /&gt;	On a daily basis we have a need to clone a set of VM's to our Hot/Hot/DR site. (Each site acts as DR to the other for specific applications and some application are spanned/Load Balanced between the two. &lt;br clear="all" /&gt;	The first file SC_DR_E.cfg established what work to do by setting the details for the other scripts to interprit. &lt;br clear="all" /&gt;	The Second file SC_DR.ps1 determines if its an Odd or Even day (As we keep online 2 days working of clones in case anything failed we alway have backup at both locations.). &lt;br clear="all" /&gt;	Third file SC_CloneVM_Task.ps1 does the actual work and if requested send a ASCII email with the output during the process. &lt;br clear="all" /&gt;	If you have any questions post them to this forum and I am sure someone will answer your questions.&lt;/blockquote&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;br /&gt;
&lt;b&gt;This document was generated from the following thread:&lt;/b&gt; &lt;a class="jive-link-thread" href="http://communities.vmware.com/thread/180822"&gt;Live Cloning with Powershell - Across Clusters/Hosts not working (Help! Please!)&lt;/a&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">live</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">cloning</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vmclone</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">dr</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">cluster</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vitoolkit</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <pubDate>Tue, 03 Feb 2009 21:05:09 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9422</guid>
      <dc:date>2009-02-03T21:05:09Z</dc:date>
      <clearspace:dateToText>9 months, 3 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>Report on all VMs with snapshots</title>
      <link>http://communities.vmware.com/docs/DOC-9297</link>
      <description>&lt;br /&gt;
Snapshots are one of those things that tend to get created and then forgotten over time until you run out of disk space and can't quite figure out why. The script below will give you a handy way to generate a tabular report showing all of your VMs that have snapshots and when they were created. Its a quick "two liner", with the first line just getting you connected to your VC, and the 2nd line doing the heavy lifting of enumerating all of the VMs, finding the shapshots, looking up what host currently houses the VM and then creating the actual table&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;connect-viserver &lt;i&gt;VCServerName&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;get-vm | get-snapshot | Select-Object VM, Name, Description, PowerState, Created, @{Name="Host"; Expression = {(Get-VM $_.VM).Host.Name}} | ft -auto&lt;/li&gt;
&lt;/ol&gt;
The output looks like&lt;br /&gt;
&lt;br /&gt;
&lt;table class="jive-wiki-table"&gt;
&lt;tr&gt;
&lt;td&gt;VM&lt;/td&gt;
&lt;td&gt;Name&lt;/td&gt;
&lt;td&gt;Description&lt;/td&gt;
&lt;td&gt;PowerState&lt;/td&gt;
&lt;td&gt;Created&lt;/td&gt;
&lt;td&gt;Host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;S5&lt;/td&gt;
&lt;td&gt;Pre 4.1 Upgrades&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;PoweredOn&lt;/td&gt;
&lt;td&gt;11/21/2008 7:13:27 AM&lt;/td&gt;
&lt;td&gt;abc.domain.com&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;W2K3-Router&lt;/td&gt;
&lt;td&gt;Test Snapshot&lt;/td&gt;
&lt;td&gt;Test description&lt;/td&gt;
&lt;td&gt;PoweredOn&lt;/td&gt;
&lt;td&gt;1/8/2009 1:12:10 AM&lt;/td&gt;
&lt;td&gt;abc.domain.com&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BT&lt;/td&gt;
&lt;td&gt;Pre WSS&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;PoweredOff&lt;/td&gt;
&lt;td&gt;8/10/2008 11:38:37 PM&lt;/td&gt;
&lt;td&gt;def.domain.com&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;br clear="left" /&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">snapshot</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">reporting</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <pubDate>Sun, 11 Jan 2009 04:45:51 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9297</guid>
      <dc:date>2009-01-11T04:45:51Z</dc:date>
      <clearspace:dateToText>10 months, 2 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>VMotion Check</title>
      <link>http://communities.vmware.com/docs/DOC-9191</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">vmotion</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">report</category>
      <pubDate>Mon, 15 Dec 2008 15:31:35 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-9191</guid>
      <dc:date>2008-12-15T15:31:35Z</dc:date>
      <clearspace:dateToText>11 months, 1 week ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>NARPC (Not Another Resource Pool Copier)</title>
      <link>http://communities.vmware.com/docs/DOC-8400</link>
      <description>This script copies a hierarchical tree of resource pools from one cluster to another.&lt;br /&gt;
&lt;br /&gt;
It can easily be adapted to not to use Clusters as the starting point.&lt;br /&gt;
&lt;br /&gt;
As usual, use at your own risk.&lt;br /&gt;
&lt;br /&gt;
Oct 27: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The script now optionally copies resource group permissions thanks to work by ekjreci and lucd.&lt;/li&gt;
&lt;li&gt;The script also tries to use cmdlet/function like command-line arguments (e.g., -FromCluster cluster) when calling scripts and will prompt for 'from' and 'to' cluster names&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Thu, 23 Oct 2008 12:55:39 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-8400</guid>
      <dc:date>2008-10-23T12:55:39Z</dc:date>
      <clearspace:dateToText>1 year, 3 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>NADUS (Not Another Data Upload Script)</title>
      <link>http://communities.vmware.com/docs/DOC-8381</link>
      <description>In the environment we are working in, we want our CDROM images to be available from shared storage accessible from any ESX server, but for various reasons (corporate standards mostly, although network utilization and additional protocols on the ESX server were a factor) didn't want to use NFS or SMB.  Also, because this is the first VMware deployment for this organization, the change management organizations don't want to use templates and therefore want to build VM's using the same processes as for their metal servers.  Hence the need for the ISOs.  Finally, we didn't want to have to teach the Configuration Management/Package Deployment people how to use WinSCP to upload ISOs.&lt;br /&gt;
&lt;br /&gt;
So this script:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Goes through a Windows folder tree which has been populated with media by our configuration management/deployment folks.&lt;/li&gt;
&lt;li&gt;Replicates that tree into a VMFS datastore which is implemented on our SAN and published to all our ESX servers.&lt;/li&gt;
&lt;li&gt;Uploads any file it finds in the windows folder tree to the corresponding folder on the VMFS partition&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
You will never use this script as written, however there may be useful concepts such as: &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;how to upload files to VMware datastores.  These techniques can be adapted to uploading data to other targets such as the ESX hosts URL&lt;/li&gt;
&lt;li&gt;how to find the datacenter a store is located in&lt;/li&gt;
&lt;li&gt;how to use recursion in powershell functions&lt;/li&gt;
&lt;li&gt;find out where the Datastore psdrive is useful and where it might be tweaked in a future version&lt;/li&gt;
&lt;li&gt;how to upload to a VC-aware datastore using only your current windows credentials.  Note that if your ESX/ESXi server is not part of a VC environment, you will need valid ESX credentials&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
This script borrows extensively from the cmdlets Carter Shanklin has uploaded to &lt;a class="jive-link-external" href="http://www.codeplex.com/vitoolkitextensions"&gt;www.codeplex.com/vitoolkitextensions&lt;/a&gt;.  He and I worked together on the upload bit, and we found that the upload function requires as much memory as the largest file being uploaded.  In this case, we want to upload some pretty decent sized ISO's so this wasn't feasible since things break when you run out of memory.  The functions in this script are modified slightly to use a modest fixed amount of memory, however the upload does take significantly longer than the code in the VIToolkitExtensions  (about 10minutes for a 500MB ISO).&lt;br /&gt;
&lt;br /&gt;
This is far from perfect:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;It doesn't remove anything from the VMFS side&lt;/li&gt;
&lt;li&gt;The upload speed could be improved, but we haven't had the time to play with that&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Please use this at your own risk.  No guarantee it will work.</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">datastore</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">upload</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">esx</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">esxi</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vitoolkit_windows</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">psdrive</category>
      <pubDate>Wed, 22 Oct 2008 19:40:24 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-8381</guid>
      <dc:date>2008-10-22T19:40:24Z</dc:date>
      <clearspace:dateToText>1 year, 1 month ago</clearspace:dateToText>
    </item>
    <item>
      <title>NARMD (Not Another Removable Media Disconnector)</title>
      <link>http://communities.vmware.com/docs/DOC-8350</link>
      <description>We are using this script to provide a slightly more user-friend CDROM and floppy disconnect environment. &lt;br /&gt;
&lt;p /&gt;
You can easily disconnect all CDROMS with &lt;br /&gt;
&lt;p /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;Get-VM | Get-CDROMDrive | Set-CDROMDrive -Connected $False -Confirm:$False
&lt;/code&gt;&lt;/pre&gt; &lt;br /&gt;
&lt;p /&gt;
However you have little control over the above process, and might disconnect things that are actually in use. This script presents a list of VM's whose CDROM(s) or Floppie(s) are connected now, or are set to connect at startup, then prompts the operator to continue. &lt;br /&gt;
&lt;p /&gt;
If the operator confirms the action, it will go ahead and disconnect all the CDROMs and Floppies and uncheck the Connect At Startup, but at least the operator knows what's happening. &lt;br /&gt;
&lt;p /&gt;
If you want a log file you can invoke this as follows: &lt;br /&gt;
&lt;p /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;.\removableDrives.ps1 | Tee-Object C:\Logs\removableDrives.log
&lt;/code&gt;&lt;/pre&gt; &lt;br /&gt;
&lt;p /&gt;
Here's a sample console session (up to the prompt) &lt;br /&gt;
&lt;p /&gt;
&lt;span style="font-family:courier new"&gt;&lt;br /&gt;
VM: Server1 (PoweredOff)&lt;br /&gt;
  CD/DVD Drive 1 Connected=True ConnectAtPowerUp=True&lt;br /&gt;
  Floppy Drive 1 Connected=False ConnectAtPowerUp=False&lt;br /&gt;
VM: Server2 (PoweredOff)&lt;br /&gt;
  CD/DVD Drive 1 Connected=True ConnectAtPowerUp=True&lt;br /&gt;
  Floppy Drive 1 Connected=True ConnectAtPowerUp=True&lt;br /&gt;
VM: Workstation3 (PoweredOff)&lt;br /&gt;
  CD/DVD Drive 1 Connected=True ConnectAtPowerUp=True&lt;br /&gt;
  Floppy Drive 1 Connected=False ConnectAtPowerUp=False&lt;br /&gt;
VM: DomainController1 (PoweredOn)&lt;br /&gt;
  CD/DVD Drive 1 Connected=True ConnectAtPowerUp=True&lt;br /&gt;
  Floppy Drive 1 Connected=False ConnectAtPowerUp=True&lt;br /&gt;
Do you want to disconnect all removable drives, and disable the connect&lt;br /&gt;
  at startup?  If you don't see any VMs everything is OK and you should&lt;br /&gt;
  select N here.  Type Y or N:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;p /&gt;
The script is here for full-text searching, and is also attached. &lt;br /&gt;
&lt;p /&gt;
&lt;div class="jive-quote"&gt;&lt;span style="font-family:courier new"&gt;"removableDrives.ps1 Version 1.0a starting" &lt;br /&gt;
connect-viserver ($env:computername + "." + $env:userdnsdomain) | out-null &lt;br /&gt;
&lt;p /&gt;
Get-Vm | Where-Object {&lt;br /&gt;
(((Get-CDDrive -VM $_ | Where-Object { (($_.ConnectionState.Connected -eq $True) -or ($_.ConnectionState.StartConnected -eq $True))} ) -ne $Null) `&lt;br /&gt;
-or `&lt;br /&gt;
((Get-FloppyDrive -VM $_ | Where-Object { (($_.ConnectionState.Connected -eq $True) -or ($_.ConnectionState.StartConnected -eq $True))} ) -ne $Null))&lt;br /&gt;
} | %{&lt;br /&gt;
"VM: " + $_.Name + " (" + $_.PowerState + ")"&lt;br /&gt;
Get-CDDrive -VM $_ | ForEach-Object { " " + $_.Name + " Connected=" + $_.ConnectionState.Connected + " ConnectAtPowerUp=" + $_.ConnectionState.StartConnected }&lt;br /&gt;
Get-FloppyDrive -VM $_ | ForEach-Object { " " + $_.Name + " Connected=" + $_.ConnectionState.Connected + " ConnectAtPowerUp=" + $_.ConnectionState.StartConnected }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ("Y" -eq (Read-Host `&lt;br /&gt;
("Do you want to disconnect all removable drives, and disable the connect `n" + `&lt;br /&gt;
" at startup? If you don't see any VMs everything is OK and you should `n" + `&lt;br /&gt;
" select N here. Type Y or N"))) {&lt;br /&gt;
Get-Vm | Where-Object {&lt;br /&gt;
(((Get-CDDrive -VM $_ | Where-Object { (($_.ConnectionState.Connected -eq $True) -or ($_.ConnectionState.StartConnected -eq $True))} ) -ne $Null) `&lt;br /&gt;
-or `&lt;br /&gt;
((Get-FloppyDrive -VM $_ | Where-Object { (($_.ConnectionState.Connected -eq $True) -or ($_.ConnectionState.StartConnected -eq $True))} ) -ne $Null))&lt;br /&gt;
} | %{&lt;br /&gt;
"VM: " + $_.Name + " (" + $_.PowerState + ")"&lt;br /&gt;
Get-CDDrive -VM $_ | ForEach-Object { Set-CDDRIVE -CD $_ -StartConnected $False -Connected $False -Confirm:$False | %{ " Changed " + $_.Name} }&lt;br /&gt;
Get-FloppyDrive -VM $_ | ForEach-Object { Set-FloppyDRIVE -Floppy $_ -StartConnected $False -Connected $False -Confirm:$False | %{ " Changed " + $_.Name} }&lt;br /&gt;
}&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
"removableDrives.ps1 finished."&lt;/span&gt;&lt;/div&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">cdrom</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">set-cddrive</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <pubDate>Tue, 21 Oct 2008 16:58:25 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-8350</guid>
      <dc:date>2008-10-21T16:58:25Z</dc:date>
      <clearspace:dateToText>1 year, 1 month ago</clearspace:dateToText>
    </item>
    <item>
      <title>NAEPS (Not Another ESX Provisioning Script)</title>
      <link>http://communities.vmware.com/docs/DOC-8170</link>
      <description>This script builds on the excellent work done by lberc and others in the forums and at VMware&lt;br /&gt;
&lt;br /&gt;
We are deploying VC+ESX to a somewhat interesting environment:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;engineering is not directly involved in provisioning so it needs to be as automated as possible within a cost-effective constraint&lt;/li&gt;
&lt;li&gt;security is important&lt;/li&gt;
&lt;li&gt;We're using ESX not ESXi&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The scripts I found stopped too soon for my O-C taste, so this one goes a bit further than others I found including:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Configure the license server&lt;/li&gt;
&lt;li&gt;Upload signed SSL key and certificate files to the ESX server&lt;/li&gt;
&lt;li&gt;Rename all local datastores to try to reduce the accidental deployment to local stores&lt;/li&gt;
&lt;li&gt;Configure the firewall for NTP and updateManager&lt;/li&gt;
&lt;li&gt;Targeted for ESX although there is also a nod to ESXi provisioning&lt;/li&gt;
&lt;li&gt;Configure the environment for our special case where the VCS-ESX communications are on an isolated network&lt;/li&gt;
&lt;/ul&gt;
and a separate isolated VMotion network&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Rescan the HBAs&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
It does the "usual" stuff borrowed from lberc and others:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;reset the root password&lt;/li&gt;
&lt;li&gt;configure networks&lt;/li&gt;
&lt;li&gt;joining to VCS servers&lt;/li&gt;
&lt;li&gt;configuring NTP, DNS, domain, name, IP's etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Some interesting concepts explored here, although hints of topics on these throughout the forums&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Upload files to an https server with a self-signed SSL certificate&lt;/li&gt;
&lt;li&gt;Finding the local datastores on an ESX server&lt;/li&gt;
&lt;li&gt;Accessing and modifying the firewall configuration&lt;/li&gt;
&lt;li&gt;Dealing with Passwords entered with the Read-Host -asSecureString&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Some caveats&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;This is my first significant Powershell, .Net and VI project. I am sure many of you will cringe when you look at the arcane methods I found.&lt;/li&gt;
&lt;li&gt;We do a manual install of ESX rather than using kickstart. I expect we'll head towards ESXi and this work wouldn't have paid back. This script is run immediately after the reboot following the installation.&lt;/li&gt;
&lt;li&gt;It works pretty well in our target environment, but there is no guarantee or warranty it will work in yours.&lt;/li&gt;
&lt;li&gt;The upload stuff works here works for fairly small files. (file size=memory consumed) Carter Shanklin and I are&lt;/li&gt;
&lt;/ul&gt;
working to improve the upload process. Watch Carter's (c_shanklin) blog and his VI Toolkit Extensions at &lt;a class="jive-link-external" href="http://www.codeplex.com/vitoolkitextensions"&gt;http://www.codeplex.com/vitoolkitextensions&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
A few features for the next version of this script - perhaps in another life:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;It should really attach the server to an Update Manager baseline and remediate.&lt;/li&gt;
&lt;li&gt;Replace all the anachronisms with the best-practice methods&lt;/li&gt;
&lt;li&gt;Configure a VMKernel network and gateway on the Management VLAN&lt;/li&gt;
&lt;li&gt;A way cool Windows.Forms with drop-down lists to capture the information&lt;/li&gt;
&lt;li&gt;Automatically download backup ESXi configuration file to the local disk&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Oct 16 2008&lt;br /&gt;
&lt;br /&gt;
I meant to mention how to generate a log file but forgot.&lt;br /&gt;
&lt;br /&gt;
As you may have noticed all the messages in this script are simply dumped to the console, rather than explicitly output with Write-Host.  You can redirect this to a log file and still see the console messages by invoking the script as follows:&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;.\configureESX.ps1 | Tee-Object .\configureESX-server.log
&lt;/code&gt;&lt;/pre&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">esx</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">esxi</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">3.5</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vi_toolkit_windows</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">ssl</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">license</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">upload</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">provision</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">script</category>
      <pubDate>Sat, 11 Oct 2008 02:48:55 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-8170</guid>
      <dc:date>2008-10-11T02:48:55Z</dc:date>
      <clearspace:dateToText>1 year, 1 month ago</clearspace:dateToText>
    </item>
    <item>
      <title>Script: Map RDMs to VMs using Uuids and vm names imported from CSV</title>
      <link>http://communities.vmware.com/docs/DOC-7951</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">new-harddisk</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">rdm</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vitoolkit</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">storage</category>
      <pubDate>Thu, 25 Sep 2008 15:43:28 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-7951</guid>
      <dc:date>2008-09-25T15:43:28Z</dc:date>
      <clearspace:dateToText>1 year, 1 month ago</clearspace:dateToText>
    </item>
    <item>
      <title>Nic Teaming Policy</title>
      <link>http://communities.vmware.com/docs/DOC-7133</link>
      <description>I have another question based on the example of adding a virtual switch.  What if you also wanted to set the nicTeaming policy of the vSwitch to loadbalance_ip  and network failover detection to Link Status Only?  I see that those properities are under HostNetworkPolicy, but I'm not sure how you would use that to add that information to this.  I'm probably just making this a lot harder than it actually is.&lt;br /&gt;
&lt;br /&gt;
$HS = Find-EntityView -ViewType "HostSystem" &lt;br /&gt;
$nwSys = $HS.ConfigManager.NetworkSystem &lt;br /&gt;
$mor = Get-View -MoRef $nwSys &lt;br /&gt;
$networkConfig = New-Object Vmware.Vim.HostNetworkConfig &lt;br /&gt;
$vswtch = New-Object VMware.Vim.HostVirtualSwitchConfig &lt;br /&gt;
$networkConfig.vswitch = @($vswtch) &lt;br /&gt;
$networkConfig.vswitch[0].name = "SwitchName" &lt;br /&gt;
$spec = New-Object Vmware.Vim.HostVirtualSwitchSpec &lt;br /&gt;
$spec.numPorts = 1 &lt;br /&gt;
$portgrp = New-Object VMware.Vim.HostPortGroupConfig &lt;br /&gt;
$networkConfig.portgroup = @($portgrp) &lt;br /&gt;
$portgropspec = New-Object VMware.Vim.HostPortGroupSpec &lt;br /&gt;
$portgropspec.vswitchName = "SwitchName" &lt;br /&gt;
$portgropspec.Name = "SwitchNamePort" &lt;br /&gt;
$portgropspec.Policy = New-Object VMware.Vim.HostNetworkPolicy &lt;br /&gt;
$networkConfig.vswitch[0].spec = $spec &lt;br /&gt;
$networkConfig.portgroup[0].spec = $portgropspec &lt;br /&gt;
$mor.AddVirtualSwitch("SwitchName",$spec ) $mor.AddPortGroup($portgropspec)&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
Thanks,Jaime&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;hr /&gt;
As you probably know NIC teaming can be defined on the switch and on the portgroup.&lt;br /&gt;
This example shows how it is done on a portgroup like you asked.&lt;br /&gt;
I left out the vSwitch objects and method so as not confuse you.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;
$HS = Get-View -ViewType &lt;font color="red"&gt;&amp;quot;HostSystem&amp;quot;&lt;/font&gt; -Filter @&lt;font color="navy"&gt;{&lt;/font&gt;&lt;font color="red"&gt;&amp;quot;Name&amp;quot;&lt;/font&gt; = &amp;lt;ESX-name&amp;gt;&lt;font color="navy"&gt;}&lt;/font&gt;
$nwSys = $HS.ConfigManager.NetworkSystem
$mor = Get-View $nwSys
 
$portgropspec = New-Object VMware.Vim.HostPortGroupSpec
$portgropspec.vswitchName = &amp;lt;vswitch-name&amp;gt;
$portgropspec.Name = &amp;lt;portgroup-name&amp;gt;
 
$portgropspec.Policy = New-Object VMware.Vim.HostNetworkPolicy
 
$portgropspec.Policy.NicTeaming = New-Object VMware.Vim.HostNicTeamingPolicy
$portgropspec.Policy.NicTeaming.failureCriteria = New-Object VMware.Vim.HostNicFailureCriteria
$portgropspec.Policy.NicTeaming.failureCriteria.checkBeacon = $false
$portgropspec.Policy.NicTeaming.failureCriteria.checkDuplex = $false
$portgropspec.Policy.NicTeaming.failureCriteria.checkErrorPercent = $false
 
$portgropspec.Policy.NicTeaming.nicOrder = New-Object VMware.Vim.HostNicOrderPolicy
$portgropspec.Policy.NicTeaming.nicOrder.activeNic = @(&amp;lt;NIC1-name&amp;gt;)
$portgropspec.Policy.NicTeaming.nicOrder.standbyNic = @(&amp;lt;NIC2-name&amp;gt;)
$portgropspec.Policy.NicTeaming.policy = &lt;font color="red"&gt;&amp;quot;loadbalance_ip&amp;quot;&lt;/font&gt;
 
$mor.AddPortGroup($portgropspec)
&amp;nbsp;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Note1: in v1 of the VITK the functionality of the Find-EntityView cmdlet has been replaced by the Get-View cmdlet&lt;br /&gt;
Note2: for &amp;lt;vswitch-name&amp;gt; you use the name of an existing switch&lt;br /&gt;
Note3: "Link Status Only" is the default setting. All flags in the failureCriteria object are set to $false&lt;br /&gt;
Note4: for NIC1-name and NIC2-name you use 2 NICs that are already allocated to the vswitch&lt;br /&gt;
Note5: the choice for Active-Active or Active-Standby is up to you. If you place the 2 NICs in the activeNic array , as @(&amp;lt;NIC1-name&amp;gt;,&amp;lt;NIC2-name&amp;gt;), you will have Active-Active teaming.&lt;br /&gt;
&lt;p /&gt;
&lt;hr /&gt;
Awesome, thanks for helping me out again.  I am using v1 so I have been using the Get-View cmlet.  I just copied the example from the FAQ page. &lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
Jaime&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
This document was generated from the following thread: &lt;a class="jive-link-thread" href="http://communities.vmware.com/thread/163401"&gt;Nic Teaming Policy&lt;/a&gt;</description>
      <pubDate>Mon, 18 Aug 2008 15:30:44 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-7133</guid>
      <dc:date>2008-08-18T15:30:44Z</dc:date>
      <clearspace:dateToText>1 year, 3 months ago</clearspace:dateToText>
    </item>
    <item>
      <title>How To: Configure freshly booted ESX with PowerShell</title>
      <link>http://communities.vmware.com/docs/DOC-7132</link>
      <description>As part of a larger project I've been working on a set of scripts which configure a freshly-installed ESX (or ESXi) system into Virtual Center (after first attempting to remove previous VC state and clean state from the host).  Currently they follow a typical post-boot configuration pattern:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Set ESX password&lt;/li&gt;
&lt;li&gt;Add to Virtual Center cluster&lt;/li&gt;
&lt;li&gt;Configure Virtual Switches&lt;/li&gt;
&lt;li&gt;Configure Port Groups&lt;/li&gt;
&lt;li&gt;Add NFS partitions&lt;/li&gt;
&lt;li&gt;Add iSCSI partitions&lt;/li&gt;
&lt;li&gt;Configure NTP&lt;/li&gt;
&lt;li&gt;Configure VMotion&lt;/li&gt;
&lt;/ol&gt;
Before trying, modify esx-master.ps1 and esx-profile.ps1 to local conditions (or your password will be set to "CHANGEME").&lt;br /&gt;
&lt;br /&gt;
Command: esx-autoconfigure.ps1 "hostname|ip-address"&lt;br /&gt;
&lt;br /&gt;
As this is my initial foray into PowerShell, please excuse any idiosyncracies. &lt;br /&gt;
&lt;br /&gt;
This is a work-in-progress - feedback welcome.  Points awarded for the best suggestions in the next few days. &lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
lance&lt;br /&gt;
&lt;p /&gt;
(See &lt;a class="jive-link-wiki" href="http://communities.vmware.com/docs/DOC-7512" title="How to PXE boot and automatically configure Stateless VMware ESXi Server.  The configuration tools will also work against ESX Classic."&gt;boot/config doc).&lt;/a&gt;&lt;hr /&gt;
My comments are as follows:&lt;br /&gt;
&lt;br /&gt;
1. &lt;a class="jive-link-external" href="http://www.vmware.com/landing_pages/toolkit_contest.html"&gt;http://www.vmware.com/landing_pages/toolkit_contest.html&lt;/a&gt;&lt;br /&gt;
2. Cool, &lt;img class="jive-emoticon" border="0" src="http://communities.vmware.com/images/emoticons/happy.gif" alt=":)" /&gt;  I've been working on something similar for a project at work (not to mention for my book).&lt;br /&gt;
3. I'm a judge for #1, so I'll refrain from commenting directly on your code in case you decide to submit it, which I suggest you do.&lt;br /&gt;
&lt;br /&gt;
Author of the upcoming book: &lt;a class="jive-link-external" href="http://sapienpress.com/vmware.asp"&gt;Managing VMware Infrastructure with PowerShell&lt;/a&gt;&lt;br /&gt;
Co-Host, PowerScripting Podcast (&lt;a class="jive-link-external" href="http://powerscripting.net"&gt;http://powerscripting.net&lt;/a&gt;)&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;hr /&gt;
Some suggestions:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;configure or check DNS and gateways before steps 3/4/7/8. Critical for clustering, HA and DRS!&lt;/li&gt;
&lt;li&gt;configure the firewall&lt;/li&gt;
&lt;li&gt;(eventually) configure some advanced ESX settings. See for example a recent discussion about NFS.MaxVolumes&lt;/li&gt;
&lt;li&gt;check (and eventually configure) licensing before using clustering with HA/DRS/vMotion&lt;/li&gt;
&lt;li&gt;configure (or adjust) resource pool(s). Adding an ESX server will increase the available resources.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
Very nice, you should definately enter the comp.&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;br /&gt;
Alan Renouf&lt;br /&gt;
VMware, Citrix, Microsoft Consultant&lt;br /&gt;
UK&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;a class="jive-link-external" href="http://teckinfo.blogspot.com/"&gt;My Blog&lt;/a&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;br /&gt;
&lt;hr /&gt;
iberc,&lt;br /&gt;
&lt;br /&gt;
I'm doing a large roll-out of esxi. I have been working on the exact same as what you're doing. If I can add anything across what you got i may post it.&lt;br /&gt;
&lt;br /&gt;
You're scripts look to be more portable. This is my first dive into significant scripting not to mention powershell. The envronment i'm building for is very homogenous so the work reflects it. this is definately work in progress. these files on their own need to be edited etc and linked.&lt;br /&gt;
&lt;p /&gt;
I've been looking for awhile now for configuration of ESXi via powershell and it seems very limited.  Most resources are directed at management of existing.&lt;br /&gt;
&lt;br /&gt;
Message was edited by: olan025&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;hr /&gt;
Lance works for VMware, no $5000 for him, for us 3rd prize is we're fired &lt;img class="jive-emoticon" border="0" src="http://communities.vmware.com/images/emoticons/sad.gif" alt=":(" /&gt;&lt;br /&gt;
&lt;hr /&gt;
My cover has been blown. - l&lt;br /&gt;
&lt;hr /&gt;
Looks great! &lt;br /&gt;
&lt;br /&gt;
Lance, do you know Aiden Dalgleish? He's a PSO Consultant from the UK and already created a hell of a lot scripts for installing. Talk to him, he's got some cool stuff!&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
Duncan&lt;br /&gt;
My virtualisation blog:&lt;br /&gt;
&lt;a class="jive-link-external" href="http://www.yellow-bricks.com"&gt;http://www.yellow-bricks.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you find this information useful, please award points for "correct" or "helpful".&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;hr /&gt;
Hal,&lt;br /&gt;
&lt;br /&gt;
How about making an exception to allow me a sneak peak at your new book? My scripting needs to be tuned up as you can tell i'm a beginner if you looked at my earlier attachments.&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;br /&gt;
I'm making changes and updates to those, if anyone does care for them post it. otherwise my stuff is pretty basic compared to Lance's functionalized code.&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;br /&gt;
This document was generated from the following thread: &lt;a class="jive-link-thread" href="http://communities.vmware.com/thread/161304"&gt;How To: Configure freshly booted ESX with PowerShell&lt;/a&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">installation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">pxe</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">midwife</category>
      <pubDate>Mon, 18 Aug 2008 15:28:14 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-7132</guid>
      <dc:date>2008-08-18T15:28:14Z</dc:date>
      <clearspace:dateToText>10 months, 6 days ago</clearspace:dateToText>
    </item>
    <item>
      <title>How to Move a Template</title>
      <link>http://communities.vmware.com/docs/DOC-7120</link>
      <description>I was surprised this morning to find that you can't directly move templates using the existing cmdlets.  Looks like you can either a) change template to a VM using set-template or b) use Get-View on a Folder object and then call its &lt;a class="jive-link-external" href="http://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.Folder.html#moveInto"&gt;MoveIntoFolder&lt;/a&gt; method.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Method A&lt;/b&gt; - there and back again&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$vm = Get-Template wind* | Set-Template -ToVM | 
	Move-VM -Destination (Get-Folder templates) 
$vmView = $vm | Get-View
$vmView.MarkAsTemplate()
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
TotalSeconds      : 8.9222029&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Method B&lt;/b&gt; - do it folder style&lt;br /&gt;
&lt;br /&gt;
This one should be much faster...let's see:&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$TmplView = Get-Template wind* | Get-View
$FolderView = Get-Folder Templates | Get-View
$FolderView.MoveIntoFolder( $TmplView.MoRef )
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
TotalSeconds      : 2.0466224&lt;br /&gt;
&lt;br /&gt;
We have a winner &lt;img class="jive-emoticon" border="0" src="http://communities.vmware.com/images/emoticons/happy.gif" alt=":)" /&gt;&lt;br /&gt;
&lt;br /&gt;
Note that the timing was performed on my home lab.  I imagine on nice hardware method B would take less than a second.</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">template</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">performance</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">get-view</category>
      <pubDate>Sun, 17 Aug 2008 16:33:13 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-7120</guid>
      <dc:date>2008-08-17T16:33:13Z</dc:date>
      <clearspace:dateToText>1 year, 3 months ago</clearspace:dateToText>
    </item>
    <item>
      <title>Script: Create Disaster Recovery Hard Drive, with Backup-VM VCB Wrapper CMDLet</title>
      <link>http://communities.vmware.com/docs/DOC-6280</link>
      <description>&lt;h6&gt;Update 27-Aug-08: Script updated for VI Toolkit 1.0 and Powershell v2 CTP2&lt;/h6&gt;
&lt;h1&gt;Create Disaster Recovery Hard Drive&lt;/h1&gt;
&lt;h2&gt;Motivation &lt;/h2&gt;
This script was created out of a motivation of laziness. Since VM's proliferate so fast, most backup and disaster recovery solutions are a pain in the ass because you have to manually add and remove virtual machines to their backup processes. What if there was a way to automatically add and remove VM's to a backup solution simply because of where they are located in Virtualcenter? What if I had an automated DR solution to removable USB hard drives for my smaller clients that was FREE? &lt;br /&gt;
&lt;br /&gt;
Hence this script. This script dynamically backs up all VM's in a particular Virtualcenter folder using VCB, and drops them out to a USB hard drive for disaster recovery purposes. If I don't want a VM backed up anymore, I simply take it out of that folder. &lt;br /&gt;
&lt;br /&gt;
Note that this also leverages the new networked method of VCB, so &lt;b&gt;YOU DO NOT NEED A SAN AND DIRECT ACCESS TO THE LUNs.&lt;/b&gt; &lt;br /&gt;
&lt;br /&gt;
The script is also flexible enough so that if you do have the SAN VCB configuration, you can do LAN-free backups with this method too. &lt;br /&gt;
&lt;br /&gt;
Note that the query here is just an example. Any way you can return a list of VM's, you can give it to the backup-vm cmdlet. &lt;br /&gt;
&lt;br /&gt;
Some examples that come to mind: &lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Backup all virtual machines with disks under 500MB in size&lt;/li&gt;
&lt;li&gt;Backup all virtual machines created after July 1st&lt;/li&gt;
&lt;li&gt;Backup all virtual machines with "Prod" in their names&lt;/li&gt;
&lt;li&gt;Backup all virtual machines with a custom attribute defined called "BackMeUp" set to true&lt;/li&gt;
&lt;li&gt;Backup all virtual machines currently residing on a particular host, cluster, or datacenter.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
This script took me about 8 hours, mostly because I was learning how to do script cmdlets and dealing with all the incompatabilities/breakage of CTP Powershell releases as well. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Script Cmdlets&lt;/h2&gt;
The task evolved into my first foray into the new Script Cmdlets in Powershell v2. They're so easy to make I went wild and wrote a near-complete wrapper to VCB. Cut and paste the "cmdlet" section out of the code and put it in your profile, and you can now use the Backup-VM cmdlet. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Install onto a server or workstation with the prerequisites defined in the script (VCB, Powershell v2 CTP2, VI Toolkit v1.0)&lt;/li&gt;
&lt;li&gt;Edit the parameters of the script to suit your environment. &lt;b&gt;BE VERY CAREFUL WITH VMBackupDestination&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Run to test, then set up as a scheduled task on a daily interval.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Example Screenshot:&lt;br /&gt;
&lt;a class="jive-link-external" href="http://i36.tinypic.com/5zeel1.png"&gt;VCB Backup Script in Action&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Script&lt;/h2&gt;
Due to issues with VMWare Communities, the script is now attached to this document.</description>
      <pubDate>Mon, 14 Jul 2008 14:47:56 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-6280</guid>
      <dc:date>2008-07-14T14:47:56Z</dc:date>
      <clearspace:dateToText>1 year, 2 months ago</clearspace:dateToText>
      <clearspace:replyCount>2</clearspace:replyCount>
    </item>
    <item>
      <title>Script: VMWare Lab Manager Automatic Cleanup</title>
      <link>http://communities.vmware.com/docs/DOC-6125</link>
      <description>&lt;h2&gt;Motivation &lt;/h2&gt;
In the official documentation they say that you shouldn't use Lab Manager and Virtualcenter to manage the same ESX Hosts. Since I don't have the luxury of investing in dedicated ESX Servers for my lab, I decided to write a script that automatically moves Lab Manager-created VM's into a specific folder and resource pool, and automatically removes undeployed Lab Manager VM's from the inventory. &lt;br /&gt;
&lt;br /&gt;
This keeps my VirtualCenter organized and puts the Lab Machines in low-end resource pools so that my production VM's still get their reserves and SLA shares. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Powershell&lt;/li&gt;
&lt;li&gt;VI Toolkit for Windows&lt;/li&gt;
&lt;li&gt;A VirtualCenter user with rights to browse through VirtualCenter and Move VM's&lt;/li&gt;
&lt;li&gt;Access to the SSL port of your Virtualcenter server from the host you run the script (i.e. not firewalled).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
First, edit the script and change the constants so that they match your environment:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Lab Manager Resource Pool&lt;/b&gt; - Which resource pool you want your Lab Manager VMs to reside (ex. "MyLab")&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Lab Manager Folder&lt;/b&gt; - Same as above but a folder under Virtual Machines and Templates&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Virtualcenter Server&lt;/b&gt; - Your VC Server. Note that the name here must match the name on your virtualcenter SSL certificate.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;VC Username&lt;/b&gt; - The user to connect to VirtualCenter as. I recommend a service account but you can use "administrator" if you want.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;VC Password&lt;/b&gt; - Password for the user. Yes, I know it is in cleartext in the script, but since it's on my VC server using a low-privilege service account and I apply strict permissions to the files there, I'm not worried. If this bothers you, look up the SecureCredentials stuff in powershell.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
I set up this to run as a scheduled task on my VirtualCenter server every 5 minutes, but it can run anywhere that has the VI Toolkit and access to the VirtualCenter SSL port.&lt;br /&gt;
&lt;br /&gt;
I recommend creating a service account to run the script periodically under, because it looks cool in your Virtualcenter when a bunch of cleanup tasks owned by "LabManagerCleanup" come up every 5 minutes. &lt;br /&gt;
&lt;br /&gt;
Huge thanks to the VI Toolkit team! The meat of the script is probably only about 10-15 lines and makes some direct VMWare SDK accesses that the base cmdlets don't do, I've just added a ton of comments and colored output fluff. Powershell saved me &lt;b&gt;so&lt;/b&gt; much time, I banged this out in a couple hours.&lt;br /&gt;
&lt;p /&gt;
Hope this helps anyone else out there! I know there's some kludgy logic in this script and I note it, but I'm a consultant/admin, not a programmer, and it works just fine. Feel free to make it better!&lt;br /&gt;
&lt;p /&gt;
&lt;b&gt;NOTE: The below may not format well in some versions of IE7. View it in Firefox and it should be line-carriaged properly.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;# TITLE: 	Lab Manager Cleanup Script
# AUTHOR:	Justin Grote &amp;lt;jgrote*NO*@!SPAM!enpointe.|PLEASE|com&amp;gt;
# PURPOSE:	Cleans up undeployed Lab Manager VM&lt;font color="navy"&gt;'s, and puts deployed Lab Manager VM'&lt;/font&gt;s 
# 			into specific resource pools and folders
# USAGE:	Edit Constants to match your environment, run once manually to test, then schedule as repeating task.
 
#Load the VI Toolkit &lt;font color="navy"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; Powershell
add-pssnapin VMWare.VimAutomation.Core
 
## CONSTANTS
 
#Virtualcenter Server Name
$VCNAME = &lt;font color="red"&gt;&amp;quot;virtualcenter.yourcompany.com&amp;quot;&lt;/font&gt;
 
#VirtualCenter Service Account
#NOTE: Highly recommended &lt;font color="navy"&gt;&lt;b&gt;this&lt;/b&gt;&lt;/font&gt; be a separate service account such as &lt;font color="red"&gt;&amp;quot;VMLabMgrSA&amp;quot;&lt;/font&gt; so it is easy
#      to see in Virtualcenter when the script is moving things about.
$VCUSER = &lt;font color="red"&gt;&amp;quot;username&amp;quot;&lt;/font&gt;
$VCPASSWORD = &lt;font color="red"&gt;&amp;quot;yourpassword&amp;quot;&lt;/font&gt;
 
#Desired Lab Resource Pool Name
$LABMGRPOOLNAME = &lt;font color="red"&gt;&amp;quot;MyLabManagerResourcePool&amp;quot;&lt;/font&gt;
 
#Desired Virtualcenter Folder
$LABMGRFOLDERNAME = &lt;font color="red"&gt;&amp;quot;MyLabManagerFolder&amp;quot;&lt;/font&gt;
 
#Creates an indentation &lt;font color="navy"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; subtasks. Used &lt;font color="navy"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; script output formatting
$INDENT = &lt;font color="red"&gt;&amp;quot;  &amp;quot;&lt;/font&gt;
 
### SCRIPT
write-host -fore green &lt;font color="red"&gt;&amp;quot;== BEGIN LAB MANAGER CLEANUP ==&amp;quot;&lt;/font&gt;
 
#Connect to Virtualcenter
$vc = get-viserver $VCNAME -user $VCUSER -password $VCPASSWORD
 
#Lab Manager Resource Pool
$LabMgrPool = get-resourcepool $LABMGRPOOLNAME
 
#Lab Manager Virtualcenter Folder
$LabMgrFolder = get-folder $LABMGRFOLDERNAME
 
#Discover all Lab Manager VM&lt;font color="navy"&gt;'s. &lt;/font&gt;
#Note &lt;font color="navy"&gt;&lt;b&gt;this&lt;/b&gt;&lt;/font&gt; is done really sloppily by looking &lt;font color="navy"&gt;&lt;b&gt;for&lt;/b&gt;&lt;/font&gt; all VM&lt;font color="navy"&gt;'s that have a .vmx file in a &lt;/font&gt;
#specific datastore folder that Lab Manager manages. 
#A Better way would be to query some sort of Lab Manager API.
$LabMgrVMs = get-vm | where &lt;font color="navy"&gt;{&lt;/font&gt;(get-view $_.ID).summary.config.vmpathname -like &lt;font color="red"&gt;&amp;quot;*] VM/*&amp;quot;&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt;
 
 
## TASK 1: Move All Virtual Machines to the designated Lab Manager Folder and Resource Pool
 
write-host -fore green &lt;font color="red"&gt;&amp;quot;Moving Lab Manager Virtual Machines to their desired locations...&amp;quot;&lt;/font&gt;
foreach ($LabMgrVM in $LabMgrVMs) &lt;font color="navy"&gt;{&lt;/font&gt;
 
  #Verify that the VM is not already in the desired folder and move it.
  &lt;font color="navy"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; (-not ($(get-vm -location $LabMgrFolder | foreach&lt;font color="navy"&gt;{&lt;/font&gt;$_.get_ID() &lt;font color="navy"&gt;}&lt;/font&gt;) -contains $LabMgrVM.get_ID() )) &lt;font color="navy"&gt;{&lt;/font&gt;
    write-host -fore Yellow $INDENT &lt;font color="red"&gt;&amp;quot;Moving&amp;quot;&lt;/font&gt; $LabMgrVM.Name &lt;font color="red"&gt;&amp;quot;to folder&amp;quot;&lt;/font&gt; $LabMgrFolder.Name
    move-VM $LabMgrVM -Location $LabMgrFolder | out-&lt;font color="navy"&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;
  &lt;font color="navy"&gt;}&lt;/font&gt;
  &lt;font color="navy"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt; &lt;font color="navy"&gt;{&lt;/font&gt;
    write-host $INDENT $LabMgrVM.Name &lt;font color="red"&gt;&amp;quot;is already in folder&amp;quot;&lt;/font&gt; $LabMgrFolder.Name
  &lt;font color="navy"&gt;}&lt;/font&gt;
 
  #Verify that the VM is not already in the desired resource pool and move it.
  &lt;font color="navy"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; (-not ($(get-vm -location $LabMgrPool | foreach&lt;font color="navy"&gt;{&lt;/font&gt;$_.get_ID() &lt;font color="navy"&gt;}&lt;/font&gt;) -contains $LabMgrVM.get_ID() )) &lt;font color="navy"&gt;{&lt;/font&gt;
    write-host -fore Yellow $INDENT &lt;font color="red"&gt;&amp;quot;Moving&amp;quot;&lt;/font&gt; $LabMgrVM.Name &lt;font color="red"&gt;&amp;quot;to resource pool&amp;quot;&lt;/font&gt; $LabMgrPool.Name
    move-VM $LabMgrVM -Location $LabMgrPool | out-&lt;font color="navy"&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;
  &lt;font color="navy"&gt;}&lt;/font&gt;
  &lt;font color="navy"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt; &lt;font color="navy"&gt;{&lt;/font&gt;
    write-host $INDENT $LabMgrVM.Name &lt;font color="red"&gt;&amp;quot;is already in resource pool&amp;quot;&lt;/font&gt; $LabMgrPool.Name
  &lt;font color="navy"&gt;}&lt;/font&gt;
&lt;font color="navy"&gt;}&lt;/font&gt;
 
 
## TASK 2: Clean up all undeployed Lab Manager VMs.
 
write-host -fore green &lt;font color="red"&gt;&amp;quot;Cleaning up all undeployed Lab Manager VMs&amp;quot;&lt;/font&gt;
 
#Get all Lab Manager VM&lt;font color="navy"&gt;'s listed in the defined Lab Manager folder.&lt;/font&gt;
#I &lt;font color="navy"&gt;&lt;b&gt;do&lt;/b&gt;&lt;/font&gt; &lt;font color="navy"&gt;&lt;b&gt;this&lt;/b&gt;&lt;/font&gt; instead of getting *ALL* VM&lt;font color="navy"&gt;'s because there may be some orphaned VMs that&lt;/font&gt;
#Aren&lt;font color="navy"&gt;'t from Lab Manager that we may not want to touch&lt;/font&gt;
#Again, &lt;font color="navy"&gt;&lt;b&gt;this&lt;/b&gt;&lt;/font&gt; is sloppy, and should use some sort of Lab Manager API
$LabMgrRegisteredVMs = get-vm -location $LabMgrFolder
 
#Check &lt;font color="navy"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; any Lab Manager VM&lt;font color="navy"&gt;'s are orphaned, and remove them from the inventory.&lt;/font&gt;
foreach ($LabMgrVM in $LabMgrRegisteredVMs) &lt;font color="navy"&gt;{&lt;/font&gt;
  &lt;font color="navy"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt; ((get-view $LabMgrVM.get_ID() ).runtime.ConnectionState -like &lt;font color="red"&gt;&amp;quot;orphaned&amp;quot;&lt;/font&gt;) &lt;font color="navy"&gt;{&lt;/font&gt;
    write-host $INDENT &lt;font color="red"&gt;&amp;quot;Removing orphaned VM&amp;quot;&lt;/font&gt; $LabMgrVM.Name &lt;font color="red"&gt;&amp;quot;from inventory.&amp;quot;&lt;/font&gt;
    remove-VM $LabMgrVM -confirm:$false | out-&lt;font color="navy"&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;
  &lt;font color="navy"&gt;}&lt;/font&gt;
&lt;font color="navy"&gt;}&lt;/font&gt;
 
write-host -fore green &lt;font color="red"&gt;&amp;quot;== END LAB MANAGER CLEANUP ==&amp;quot;&lt;/font&gt;
### END SCRIPT
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
&lt;br /&gt;
&lt;hr /&gt;
Justin Grote&lt;br /&gt;
Senior Systems Engineer&lt;br /&gt;
En Pointe Technologies</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">lab</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">manager</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vmware</category>
      <pubDate>Mon, 30 Jun 2008 01:15:55 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-6125</guid>
      <dc:date>2008-06-30T01:15:55Z</dc:date>
      <clearspace:dateToText>1 year, 4 months ago</clearspace:dateToText>
      <clearspace:replyCount>4</clearspace:replyCount>
    </item>
    <item>
      <title>Get-CustomField.ps1 Script</title>
      <link>http://communities.vmware.com/docs/DOC-6123</link>
      <description>&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;# TITLE: 	Get-CustomField.ps1
# AUTHOR:	Hal Rottenberg &amp;lt;hal@halr9000.com&amp;gt;
# PURPOSE:	Retrieve custom field data from any VMware Infrastructure &amp;quot;managed entity&amp;quot; 
# 			(i.e. VM, VMHost, Cluster, etc.).
# USAGE:	Use a Get cmdlet such as Get-VM or Get-Inventory and pipe to this script.
#			Optionally, specify the Name parameter to modify items retrieved.  Wildcards
#			are permitted.
# INPUT:	By pipeline only, any managed entity.
# OUTPUT:	A custom object containing the fields Name, Value, InputObject, and Type
# EXAMPLE:	
# PS&amp;gt; Get-Inventory | Get-CustomField.PS1 -name Service*
# 
# Name                    Value                  InputObject            Type
# ----                    -----                  -----------            ----
# ServiceLevel            Gold                   192.168.0.51           VMHostImpl

param (
	$Include # Search by this custom field name (aka key)
)
Process {
	# If the object on the pipeline does not have a CustomFields property, ignore it
	if ( !$_.CustomFields ) { continue }
	# Save this for later inclusion into the output custom object.
	$InputObject =  $_
	# An entity can be one of several types, it may be useful to know which one.
	$Type = $InputObject.GetType().Name
	$_.CustomFields | ForEach-Object {
		# If Name was provided, filter out the non-matches
		if ( ( $Name -and ( $_.Key -like $Name )) -or !$Name ) {
			# Build custom object to hold output.
			$Process = New-Object PSObject
			$Process | Add-Member -MemberType NoteProperty -Name Name -Value $_.Key -PassThru |
				Add-Member -MemberType NoteProperty -Name Value $_.Value -PassThru |
				Add-Member -MemberType NoteProperty -Name InputObject -Value $InputObject -PassThru |
				Add-Member -MemberType NoteProperty -Name Type -Value $Type
			Write-Output $Process
		}
	}
}
&lt;/code&gt;&lt;/pre&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">customfield</category>
      <pubDate>Sun, 29 Jun 2008 21:15:50 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-6123</guid>
      <dc:date>2008-06-29T21:15:50Z</dc:date>
      <clearspace:dateToText>1 year, 4 months ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
    <item>
      <title>VI Toolkit (for Windows) (Very) Unofficial Extensions</title>
      <link>http://communities.vmware.com/docs/DOC-6051</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">cmdlet</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vmware</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">module</category>
      <pubDate>Mon, 23 Jun 2008 20:13:26 GMT</pubDate>
      <author>cshanklin@vmware.com</author>
      <guid>http://communities.vmware.com/docs/DOC-6051</guid>
      <dc:date>2008-06-23T20:13:26Z</dc:date>
      <clearspace:dateToText>1 year, 2 months ago</clearspace:dateToText>
      <clearspace:replyCount>4</clearspace:replyCount>
    </item>
    <item>
      <title>Specify the boot devices for a virtual machine</title>
      <link>http://communities.vmware.com/docs/DOC-4782</link>
      <description>The below Powershell script is (heavily) based on &lt;a class="jive-link-external" href="http://download3.vmware.com/sample_code/Perl/VMBootOrder.html"&gt;this Perl script&lt;/a&gt;.&lt;br /&gt;
It uses a feature that is available with &lt;b&gt;VC2.5&lt;/b&gt; or later and &lt;b&gt;ESX 3.5&lt;/b&gt; or later.&lt;br /&gt;
&lt;br /&gt;
The keyword "&lt;b&gt;bios.bootDeviceClasses&lt;/b&gt;" allows to define the boot devices in the VMX file.&lt;br /&gt;
&lt;p /&gt;
&lt;span style="color:#ff0000"&gt;Note&lt;/span&gt;: this does not allow one to change the boot order !&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
For more info on the syntax see the Perl script.&lt;br /&gt;
&lt;br /&gt;
The following example sets the boot devices of the virtual machine to the CD drive and the hard disk.&lt;br /&gt;
&lt;p /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.extraConfig += New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = &lt;font color="red"&gt;&amp;quot;bios.bootDeviceClasses&amp;quot;&lt;/font&gt;
$spec.extraConfig[0].value = &lt;font color="red"&gt;&amp;quot;allow:cd,hd&amp;quot;&lt;/font&gt;
 
(get-view (Get-VM -Name &amp;lt;VM-name&amp;gt;).ID).ReconfigVM_Task($spec)
&amp;nbsp;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
If you want to force a boot from CD, for example for an OS deployment, only allow the CD device.&lt;br /&gt;
Once the OS installation is complete change the allowed boot devices to only the hard disk.</description>
      <pubDate>Thu, 24 Apr 2008 18:19:00 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-4782</guid>
      <dc:date>2008-04-24T18:19:00Z</dc:date>
      <clearspace:dateToText>1 year, 5 months ago</clearspace:dateToText>
      <clearspace:replyCount>2</clearspace:replyCount>
    </item>
    <item>
      <title>Managing VMware with PowerShell FAQ</title>
      <link>http://communities.vmware.com/docs/DOC-4210</link>
      <description>&lt;h1&gt;Managing VMware with PowerShell -- Frequently Asked Questions&lt;/h1&gt;
This document contains frequently asked questions about managing VMware with PowerShell. This document is a wiki page, so if you have contributions or corrections, feel free to make them by editing the document directly.&lt;br /&gt;
&lt;br /&gt;
Note: If you are using Internet Explorer, the code samples below do not render properly. To deal with this problem you can click "Edit Document" on the left hand side of the page, switch to plain text view, and copy text out of the document.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;General VI Toolkit (for Windows) Questions:&lt;/h2&gt;
Q: What is the VI Toolkit (for Windows)?&lt;br /&gt;
A: The VI Toolkit (for Windows) is a snap-in to Windows PowerShell that provides administration and automation for VMware Virtual Infrastructure.&lt;br /&gt;
&lt;br /&gt;
Q: Does this FAQ cover a particular version of the VI Toolkit (for Windows)?&lt;br /&gt;
A: Yes, this FAQ specifically covers the VI Toolkit (for Windows) 1.0, build 103777.&lt;br /&gt;
&lt;br /&gt;
Q: What VMware versions are supported?&lt;br /&gt;
A: Version 1.0 supports: VMware ESX 3.0.x, VMware ESX 3.5, VMware ESXi 3.5, VMware VirtualCenter 2.0 and VMware VirtualCenter 2.5. In addition, with the VI Toolkit (for Windows) you can manage multiple hosts at the same time, even if they are different versions of VI.&lt;br /&gt;
&lt;br /&gt;
Q: What client platforms does the VI Toolkit (for Windows) support?&lt;br /&gt;
A: Windows XP, 2003 and Vista, 32 and 64 bit versions.&lt;br /&gt;
&lt;br /&gt;
Q: What versions of PowerShell are compatible with the VI Toolkit (for Windows)?&lt;br /&gt;
A: The toolkit has been tested with PowerShell version 1, as well as the Community Technology Preview releases of PowerShell version 2.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;General PowerShell Questions:&lt;/h2&gt;
Q: How do I stop PowerShell from prompting me for confirmation before taking action?&lt;br /&gt;
A: Using parameter -Confirm one can bypass the confirmation messagebox. This parameter takes input as a Boolean. &lt;br /&gt;
Use &lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;-Confirm:$false
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: Can I manage more than one VirtualCenter server at a time? Can I connect to both ESX and VC at the same time.&lt;br /&gt;
A: Yes, but the syntax changes when you want to manage more than one host.&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;$vcs = @()
$vcs += connect-viserver &amp;lt;VC 1&amp;gt;
$vcs += connect-viserver &amp;lt;VC 2&amp;gt;
...
$vcs += connect-viserver &amp;lt;VC N&amp;gt;
 
# Snapshot all VMs across all VirtualCenter servers.
get-vm -server $vcs | new-snapshot
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;h2&gt;Initial Steps&lt;/h2&gt;
Q: How do I connect to a VirtualCenter Server or Host Server?&lt;br /&gt;
A: Use the Connect-VIServer cmdlet and provide a value to the Server parameter.&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: What if my host server listens on a non-default port?&lt;br /&gt;
A: Use the Port parameter to specify the port number.&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt; -port &amp;lt;port&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;h2&gt;VM Lifecycle:&lt;/h2&gt;
Q: How do I create a VM?&lt;br /&gt;
A: New virtual machine can be created using New-VM cmdlet. Before, executing this cmdlet first you need to connect to server. Below script would create a new virtual machine in the same host. &lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;New-VM -Name &lt;font color="red"&gt;&amp;quot;Target-VM&amp;quot;&lt;/font&gt; -Host (Get-VMHost) 
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How do I create a VM on a particular datastore?&lt;br /&gt;
A: To create a virtual machine on a particular we need the reference of the datastore. This script creates a new virtual machine on a particular datastore.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
$datastore = Get-Datastore -Name &lt;font color="red"&gt;&amp;quot;Select-Datastore-Name&amp;quot;&lt;/font&gt;
New-VM -Name &lt;font color="red"&gt;&amp;quot;Target-VM&amp;quot;&lt;/font&gt; -Host (Get-VMHost -Datastore $datastore) 
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I import an existing VM?&lt;br /&gt;
A: This script will import a VM to the vm folder.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
&amp;nbsp;
# If importing to a cluster uncomment the line below
# $rp = get-cluster &amp;lt;cluster name&amp;gt; | get-resourcepool | get-view
&amp;nbsp;
# If importing to a non-cluster host uncomment the line below
# $rp = get-vmhost &amp;lt;host name&amp;gt; | get-resourcepool | get-view
&amp;nbsp;
$vmFolder = get-view (get-folder vm).id
$vmFolder.RegisterVM_Task(&lt;font color="red"&gt;&amp;quot;[&amp;lt;Datastore Name&amp;gt;] &amp;lt;Path To VMX&amp;gt;.vmx&amp;quot;&lt;/font&gt;, &lt;font color="red"&gt;&amp;quot;&amp;lt;VM Name&amp;gt;&amp;quot;&lt;/font&gt;, $false, $rp.MoRef, $null)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I determine the connection state of CD ROM drives and floppy drives?&lt;br /&gt;
A: Connection state of CD drive and Floppy drive can be determined by property &amp;ldquo;Connected:. This return Boolean value true for connected and false for disconnected state. Below script would determine the connection state of CD and floppy drive.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
Write-Output &lt;font color="red"&gt;&amp;quot;FloppyDrive Status:&amp;quot;&lt;/font&gt;
Get-vm | Select-Object @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;Status&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;(Get-FloppyDrive -VM $_).ConnectionState.Connected&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt;, @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;Name&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.Name&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt; | ft
Write-Output &lt;font color="red"&gt;&amp;quot;CDDrive Status:&amp;quot;&lt;/font&gt;
Get-vm | Select-Object @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;Status&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;(Get-CDDrive -VM $_).ConnectionState.Connected&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt;, @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;Name&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.Name&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt; | ft
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I set VM poweron options, such as configuring tools to automatically upgrade?&lt;br /&gt;
A: By setting the ToolsUpgradePolicy property to upgradeAtPowerCycle. With this setting Tools upgrade is automatically performed on the virtual machine and rebooted if necessary. Below is the script for the same.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
$vm = Get-View (Get-VM VMName).Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo 
$vmConfigSpec.Tools.ToolsUpgradePolicy = &lt;font color="red"&gt;&amp;quot;UpgradeAtPowerCycle&amp;quot;&lt;/font&gt;
$vm.ReconfigVM($vmConfigSpec)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How do I set resources, such as limits and reservations, on a VM?&lt;br /&gt;
A: Various resources of a virtual machine can be set using the ReconfigVM_task method on virtual machine. To setting the reservation and limits of a virtual machine an instance of VirtualMachienConfigSpec would be created and all the required resources can be set in configspec befre calling the ReconfigVM_Task. Below is the script for the same.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -Server &amp;lt;Server&amp;gt; -User &amp;lt;user&amp;gt; -Password &amp;lt;password&amp;gt;
$vm = Get-VM VMName | % &lt;font color="navy"&gt;{&lt;/font&gt;Get-View $_.ID&lt;font color="navy"&gt;}&lt;/font&gt; 
$spec = new-object VMware.Vim.VirtualMachineConfigSpec
$spec.CPUAllocation = New-Object VMware.Vim.ResourceAllocationInfo
$spec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo 
$spec.CpuAllocation.Shares.Level = &lt;font color="red"&gt;&amp;quot;normal&amp;quot;&lt;/font&gt;
$spec.CpuAllocation.Limit = -1
$vm.ReconfigVM_Task($spec)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I determine the version of VMware tools my VMs are using?&lt;br /&gt;
A: Toolversion property under the config property of virtual machine object having this information. To get this information we can use the below script.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -Server &amp;lt;Server&amp;gt; -User &amp;lt;user&amp;gt; -Password &amp;lt;password&amp;gt;
get-vm VMName | % &lt;font color="navy"&gt;{&lt;/font&gt; get-view $_.ID &lt;font color="navy"&gt;}&lt;/font&gt; | select Name, @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;ToolsVersion&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.config.tools.toolsVersion&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I change a VM's IP address?&lt;br /&gt;
A: This script can be used to change the IP setting.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
 
$vmclonespec = New-Object VMware.Vim.VirtualMachineCloneSpec
$vmclonespec.Customization = New-Object  VMware.Vim.CustomizationSpec
$vmclonespec.Customization.NicSettingMap = @(New-Object VMware.Vim.CustomizationAdapterMapping)
$vmclonespec.Customization.NicSettingMap[0].Adapter = New-Object VMware.Vim.CustomizationIPSettings
$vmclonespec.Customization.NicSettingMap[0].Adapter.ip = New-Object VMware.Vim.CustomizationFixedIp
$vmclonespec.Customization.NicSettingMap[0].Adapter.Ip.IpAddress = &lt;font color="red"&gt;&amp;quot;&amp;lt;Target IP Address&amp;gt;&amp;quot;&lt;/font&gt;
$vmclonespec.Customization.Identity = New-Object vmware.Vim.CustomizationIdentitySettings
$vmclonespec.Customization.GlobalIPSettings = New-Object VMware.Vim.CustomizationGlobalIPSettings
 
$vmclonespec.config = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmclonespec.location = New-Object VMware.Vim.VirtualMachineRelocateSpec
 
$vmclonespec.powerOn = $false
$vmclonespec.template = $false
$name = &lt;font color="red"&gt;&amp;quot;Test&amp;quot;&lt;/font&gt;
 
$target = Get-Folder -Name TARGETFOLDER | % &lt;font color="navy"&gt;{&lt;/font&gt;Get-View $_.ID&lt;font color="navy"&gt;}&lt;/font&gt;  
$vmmor = Get-VM VMNAME | Get-View
$vmmor.CloneVM_Task($target.MoRef ,$name, $vmclonespec )
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How do I VMotion a VM?&lt;br /&gt;
A: This script can be used to VMotion from ESSX1 to ESX2.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -Server &amp;lt;Server&amp;gt; -User &amp;lt;user&amp;gt; -Password &amp;lt;password&amp;gt;
get-vmhost ESX1 | get-vm namevm | move-vm &amp;amp;amp;ndash;destination (get-vmhost ESX2)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;h2&gt;Snapshots:&lt;/h2&gt;
Q: How do I snapshot a VM? Multiple VMs?&lt;br /&gt;
A: New-Snapshot cmdlet can be used to create the snapshot of a virtual machine. This script will create the snapshot with name &amp;ldquo;Target-Snpsht&amp;rdquo; for all the virtual machines.&lt;br /&gt;
To do snapshot of a particular machine use Get-VM with virtual machine. Below is the script for the same.&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
New-Snapshot -Name &amp;amp;amp;ldquo;Target-Snpsht&amp;amp;amp;rdquo; -VM (Get-VM)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How do I set a VM to a particular snapshot?&lt;br /&gt;
A: A virtual machine can have multiple snapshots and any of them can be set at a time. This script can set a virtual machine to a specified snapshot.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
$vm = Get-VM -Name &amp;amp;amp;ldquo;VMName&amp;amp;amp;rdquo;
$snapshotname = $vm | Get-Snapshot -Name &amp;amp;amp;ldquo;Target-Snpsht&amp;amp;amp;rdquo;  
$vm | get-snapshot -Name &amp;amp;amp;ldquo;Target-Snpsht&amp;amp;amp;rdquo; | where &lt;font color="navy"&gt;{&lt;/font&gt; $_.name -like $snapshotname.name &lt;font color="navy"&gt;}&lt;/font&gt;  | %&lt;font color="navy"&gt;{&lt;/font&gt; set-vm $vm -snapshot $snapshotname &lt;font color="navy"&gt;}&lt;/font&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I identify all snapshots older than a particular date?&lt;br /&gt;
A: This script show snapshots more than 30 days old.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
Get-VM | Get-Snapshot | Where &lt;font color="navy"&gt;{&lt;/font&gt; $_.Created -lt (Get-Date).AddDays(-30)&lt;font color="navy"&gt;}&lt;/font&gt; | select Name, Created
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;h2&gt;ESX Host Configuration:&lt;/h2&gt;
Q: How can I create virtual switches and portgroups?&lt;br /&gt;
A: This script creates the virtual switches. &lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
 
Get-VMHost YOURHOST | New-VirtualSwitch -name &lt;font color="red"&gt;&amp;quot;My New Switch&amp;quot;&lt;/font&gt; -nic YOURNIC (e.g. vmnic1)
Get-VMHost YOURHOST | Get-VirtualSwitch -name &lt;font color="red"&gt;&amp;quot;My New Switch&amp;quot;&lt;/font&gt; | New-VirtualPortGroup -vlanid 100
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I configure NTP?&lt;br /&gt;
A: This script can be used to configure the NTP.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
$HS = Get-VMHost YOURHOST | get-view
$dtsystem =  $HS.ConfigManager.DateTimeSystem 
$mor = Get-View -MoRef $dtsystem
$dateConfig = New-Object Vmware.Vim.HostDateTimeConfig 
$hsntpConfig = New-Object VMware.Vim.HostNtpConfig 
$dateConfig.ntpConfig = $hsntpConfig 
$dateConfig.ntpConfig.server = @(&lt;font color="red"&gt;&amp;quot;&amp;lt;Your NTP Server&amp;gt;&amp;quot;&lt;/font&gt;) 
$dateConfig.timeZone = &lt;font color="red"&gt;&amp;quot;&amp;lt;Your Timezone&amp;gt;&amp;quot;&lt;/font&gt;
$mor.updateDateTimeConfig($dateConfig)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I rescan Host Bus Adapters (HBAs)?&lt;br /&gt;
A: This script used to rescan Host Bus Adapters (HBAs).&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
get-vmhost | Get-VMHostStorage -RescanAllHBA
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I display and configure the physical adapters of my ESX host.&lt;br /&gt;
A: This script display the list of physical adapters of an ESX host.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
Get-VMHost | % &lt;font color="navy"&gt;{&lt;/font&gt;Get-View $_.ID&lt;font color="navy"&gt;}&lt;/font&gt; | % &lt;font color="navy"&gt;{&lt;/font&gt;$_.name; $nics = $_.config.network.pnic; foreach ($nic in $nics)&lt;font color="navy"&gt;{&lt;/font&gt;$nic.device&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
This script can be used to configure the physical adapters of ESX host.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
 
# $nics will hold an array of physical NICs on the server.
$nics = (get-vmhost | get-vmhostnetwork).PhysicalNic
 
$nics | where &lt;font color="navy"&gt;{&lt;/font&gt; $_.DeviceName -eq &lt;font color="red"&gt;&amp;quot;NIC_TO_CONFIGURE&amp;quot;&lt;/font&gt; &lt;font color="navy"&gt;}&lt;/font&gt; | Set-VMHostNetworkAdapter -duplex full -bitratepersecmb 100
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
Q: How can I power off an ESX host?&lt;br /&gt;
A: This script can be used to power off an ESX host.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
$HS = Get-VMHost YOURHOST | get-view
$HS.ShutdownHost(&lt;font color="red"&gt;&amp;quot;false&amp;quot;&lt;/font&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;h2&gt;Reporting:&lt;/h2&gt;
Q: How can I create a tabular report of all my VMs, including their configurations and amount of disk space allocated?&lt;br /&gt;
A: This script can be used for tabular reporting of all VMs with their configuration.&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
get-vm | % &lt;font color="navy"&gt;{&lt;/font&gt; get-view $_.ID &lt;font color="navy"&gt;}&lt;/font&gt; | Select-Object Name, @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;MemoryMB&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.Summary.Config.memorySizeMB&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt; , @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;MemReservation&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.Summary.Config.memoryReservation&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt; , @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;numCpu&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.Summary.Config.numCpu&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt; , @&lt;font color="navy"&gt;{&lt;/font&gt; Name=&lt;font color="red"&gt;&amp;quot;numVirtualDisks&amp;quot;&lt;/font&gt;; Expression=&lt;font color="navy"&gt;{&lt;/font&gt;$_.Summary.Config.numVirtualDisks&lt;font color="navy"&gt;}&lt;/font&gt;&lt;font color="navy"&gt;}&lt;/font&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p /&gt;
&lt;h2&gt;Other:&lt;/h2&gt;
Q: How can I create folders that appear under "Hosts and Clusters" in VC (a so-called "Blue Folder")?&lt;br /&gt;
A: A "Blue Folder" is a folder created under the VM folder.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-java"&gt;connect-viserver -server &amp;lt;server&amp;gt; -user &amp;lt;user&amp;gt; -password &amp;lt;pwd&amp;gt;
Get-Folder vm | New-Folder -Name &amp;amp;amp;ldquo;Target-Folder-Name&amp;amp;amp;rdquo;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Q: I'm concerned about the security implications of Invoke-VMScript, how can I disable it?&lt;br /&gt;
A: Invoke-VMscript can be disabled on a VM-by-VM basis by adding this line to the VM's VMX file: monitor_control.restrict_backdoor = "true" . You can add this line by hand or you can add it with the following script:&lt;br /&gt;
&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$vmsToDisableInvoke = Get-VM &amp;lt;vms to reconfigure&amp;gt;
$vmsToDisableInvoke | foreach {
  $vm = Get-View $_.Id
  $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
  $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
  $vmConfigSpec.extraconfig[0].Key=&amp;quot;monitor_control.restrict_backdoor&amp;quot;
  $vmConfigSpec.extraconfig[0].Value=&amp;quot;true&amp;quot;
  $vm.ReconfigVM($vmConfigSpec)
}
&lt;/code&gt;&lt;/pre&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">cmdlet</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">virtualcenter</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">automation</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">faq</category>
      <pubDate>Thu, 03 Apr 2008 04:25:34 GMT</pubDate>
      <author>cshanklin@vmware.com</author>
      <guid>http://communities.vmware.com/docs/DOC-4210</guid>
      <dc:date>2008-04-03T04:25:34Z</dc:date>
      <clearspace:dateToText>9 months, 4 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>3</clearspace:replyCount>
    </item>
    <item>
      <title>PowerShell Remoting with Feedback und Targeting</title>
      <link>http://communities.vmware.com/docs/DOC-4050</link>
      <description>&lt;br /&gt;
Hey&lt;br /&gt;
&lt;p /&gt;
take a look at this extremely cool tool, which allows you to schedule and target your PowerShell scripts.&lt;br /&gt;
&lt;p /&gt;
And if this was not enough... you also get a feedback of the results.&lt;br /&gt;
&lt;p /&gt;
&lt;a class="jive-link-external" href="http://www.specopssoft.com/powershell/"&gt;http://www.specopssoft.com/powershell/&lt;/a&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">powershell</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">remoting</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">feedback</category>
      <pubDate>Mon, 31 Mar 2008 16:58:16 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-4050</guid>
      <dc:date>2008-03-31T16:58:16Z</dc:date>
      <clearspace:dateToText>1 year, 7 months ago</clearspace:dateToText>
      <clearspace:replyCount>4</clearspace:replyCount>
    </item>
    <item>
      <title>VI Toolkit (for Windows) Admin Guide</title>
      <link>http://communities.vmware.com/docs/DOC-3740</link>
      <description />
      <pubDate>Wed, 19 Mar 2008 16:02:40 GMT</pubDate>
      <author>cshanklin@vmware.com</author>
      <guid>http://communities.vmware.com/docs/DOC-3740</guid>
      <dc:date>2008-03-19T16:02:40Z</dc:date>
      <clearspace:dateToText>1 year, 8 months ago</clearspace:dateToText>
    </item>
    <item>
      <title>Creating a PSDrive to browse your inventory</title>
      <link>http://communities.vmware.com/docs/DOC-3610</link>
      <description>(I can't take credit for this, I'm just formatting and publishing instructions received from VMware.)&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Establish a connection to your the server using the Connect-VIServer command: &lt;br clear="all" /&gt; 	&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;Connect-VIServer -Server
&lt;/code&gt;&lt;/pre&gt;  &lt;br clear="all" /&gt; 	for example, &lt;br clear="all" /&gt; 	&lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;Connect-VIServer -Server 192.168.10.10
&lt;/code&gt;&lt;/pre&gt;&lt;br clear="all" /&gt; 	When prompted, provide the administrator's username and password to authenticate access on the server.&lt;/li&gt;
&lt;li&gt;Get the root folder of the server: &lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;$root = Get-Folder -NoRecursion
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Create a PowerShell drive named VI, based on the server root folder. You can use the built-in New-psDrive cmdlet. &lt;br clear="all" /&gt; &lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;New-PSDrive -Location $root -Name vi -PSProvider VimInventory -Root '\'
&lt;/code&gt;&lt;/pre&gt; &lt;br clear="all" /&gt; In this release, a single backslash is the required value for the -Root parameter.&lt;/li&gt;
&lt;li&gt;Access the new drive by typing the following command: &lt;br clear="all" /&gt; &lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;cd vi:
&lt;/code&gt;&lt;/pre&gt; &lt;br clear="all" /&gt; To list the drive content, use Get-ChildItem or its alias Dir.&lt;/li&gt;
&lt;li&gt;Navigate through your server inventory using the cd command with the full path to the host. For a fictional VI inventory it may looks like the following: &lt;pre class="jive-pre"&gt;&lt;code class="jive-code jive-plain"&gt;cd Folder01\DataCenter01\host\Web\LiveHost01
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;</description>
      <category domain="http://communities.vmware.com/tags?communityID=2530">psdrive</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">new-psdrive</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">inventory</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">provider</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">viminventory</category>
      <pubDate>Sat, 15 Mar 2008 18:33:25 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-3610</guid>
      <dc:date>2008-03-15T18:33:25Z</dc:date>
      <clearspace:dateToText>1 year, 5 days ago</clearspace:dateToText>
    </item>
    <item>
      <title>Script: Get-FolderContents</title>
      <link>http://communities.vmware.com/docs/DOC-2612</link>
      <description />
      <category domain="http://communities.vmware.com/tags?communityID=2530">folder</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">vm</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">get-view</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">get-folder</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">get-vm</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">find-entityview</category>
      <category domain="http://communities.vmware.com/tags?communityID=2530">connect-vim</category>
      <pubDate>Fri, 25 Jan 2008 17:03:15 GMT</pubDate>
      <guid>http://communities.vmware.com/docs/DOC-2612</guid>
      <dc:date>2008-01-25T17:03:15Z</dc:date>
      <clearspace:dateToText>1 year, 1 month ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
  </channel>
</rss>

