Calling all ESX admins! I am looking for novel ideas for scripts to write for the upcoming VMware Toolkit for Windows PowerShell. Yes–I am offering to do the writing. I am doing research for a project (details of which to be announced in the coming weeks), and I could use some really great ideas of missing functionality or fixes to problems you have seen while working with VMware Virtual Infrastructure 3. Pointers to something cool you have seen done with the VMware Perl Toolkit are good too. It’ll be amusing to see how much simpler those will be in PowerShell.
So please share anything you can come up with. You can leave them in the comments or contact me directly. Thanks!
Got one from IRC:
Just thought of another one myself. I’d like to easily remove one or more virtual hardware devices (such as an unnecessary sound or USB controller) across multiple systems.
You could write one to add multiple port groups across many host servers. This is so nice when trunking many VLANs at once.
Thanks Andrew, I’ll add that to my list.
A way to create a snapshot that expires in a specified number of hours would be awesome.
Hi
I would love to have a list of all active snapshots, the time they are running (or creation date), comment and VM they belong to.
Gabrie
@Mark, cool idea, I’ll see if that’s doable. @Gabrie, try this:
$snap = get-vm | get-snapshot$snap | ft @{l = "VM"; e = {$_.vm.name} },name,created,description
From the VITK forum: “I want CPU Ready information, i.e. the amount of time a VM is READY to RUN but must WAIT for a the right number of cores to become available.”
It would be nice if esxcfg-mpath commands could be used.
You can edit the SAN multipath policy and other related stuff via the VI toolkit. I’ll have to write about that someday.
How about a config script that can be used after a host has been created (initial ESX installation) that copies all the network configuration info from an existing ESX host (i.e. vswitches, portgroups, service consoles, etc) to the new host(s). (autoincrement/user input IP addresses?) or if you have made an update on one host, the script can just update all other hosts.
make it so that it can copy to all new servers or just one. I started work on this a while ago but have not had time to finish it.
“I started work on this a while ago but have not had time to finish it.”
yeah, me too.
I’m pretty sure we’ll see a script to do this come out of the VI PowerShell contest (http://vmware.com/go/powershellcontest/).
How about a script that creates a new VM based on a template and the settings in the customization wizard?
Script? That’s a one-liner!
get-template MyTemplate | new-vm -vmhost esxserver01 -name MyVM -OSCustomizationSpec MySpec
How about changing the IP address during the cloning process?
What is the difference between a Template and a virtual machine?
Right now you actually can’t change the IP during a clone using the VI Toolkit. This is a big glaring hole unfortunately.
Template is a VM that is marked as a template. It’s identical underneath the covers. But you can do more stuff with a template with regards to VM deployment.
Yes, that is a bummer, when you have to deploy 30 VMs at a time with static IP addresses.
When I did try with a known good customization tempate and the following command line command line,
get-template w2k3stdR2-template | new-vm -vmhost mytestesx01.internal.dev.org -name ScriptVM01 -OSCustomizationSpec PCK_W2k3_32BIT_STD
the process runs to about 95% then fails with this error:
8/28/2008 3:48:01 PM New-VM BB572FA5-355A-4225-BBEF-8A035305A24E The operation for the entity vm-2663 failed with the following message: “Customization failed.”
At line 3, position 99
get-template w2k3stdR2-template | new-vm -vmhost mytestesx01.internal.dev.org -name ScriptVM01 -OSCustomizationSpec PCK_W2k3_32BIT_STD
Thoughts?
is it possible to create a script that will display list of available templates (all in “template” folder) and list of all clusters and a list of all datastore that are available to the chosen cluster - so that a remote admin can simply deploy a vm from a template he selected?
Most definitely.
# list all templates in a single folder
get-folder “Templates” | get-template
Datastores are not associated with clusters, they are attached to host servers, so we have to do this:
# list datastores avail to cluster member host server
(get-cluster “DRS cluster Foo” | get-vmhost)[0] | get-datastore
The (blah)[0] stuff grabs only the first host server in the cluster. You could pipe get-vmhost to get-datastore, but you’d get duplicate results.
A slight variation on the templating one.
I’d like to maintain a machine as a live template - sitting idle on my network , picking up security updates / build tweaks and AV data.
Untill “hot cloning to template” is available ( not gone to update 2 yet ) I’m looking for a script that I can run as a scheduled task to shut a specified guest down , and clone to a template ( overwriting the last template ), then boot it back up.
I’m a complete powershell virgin but have seen the light at a recent usergroup meeting
I like it. That would not be very hard to do, I think. Which user group meeting was this?
The London one - They mentioned the book - look forward to its release !