General

Top 3 Scripts and Tools for June 2014

Each month I will be providing the Top 3 Scripts/Tools that are making a positive impact on the community. As this is the first post of this series, some of the tools/scripts may not have been first released in June, however they are valuable scripts that users should know about. This is a way that we can not only help promote the hardworking individuals in the community, but also assist others who are may benefit from the scripts provided.

1. WebCommander

Screenshot 2014-06-23 13.17.02

WebCommander is a VMware Fling that allows the user to run PowerShell and PowerCLI scripts from a web service. New scripts can be added to the web interface and customized to be run by others. WebCommander is run on a version of Windows Server 2008 or 2012 and provides users the ability to run  There are a couple of requirements:

  • Windows 2008 or 2012
  • PowerShell v3 or v4
  • PowerCLI
  • IIS 8
  • PHP 5

After deploying a Windows VM I had WebCommander up and running in less than 10 minutes. This is a great tool even for the individual user who would like a centralized view of their scripts for quick use.

To download WebCommander and learn more about how it can help you, click HERE

2. Update VMTools at PowerCycle

Luc Dekens has many great scripts scattered throughout the internet. I chose this one as I am talking with more and more customers that are currently upgrading to vSphere 5.5 and want to script the VMtools updates.

Using this script will set all virtual machines in the environment to update VMTools at PowerCycle. This can be done for individual virtual machines manually by right-clicking on a VM, selecting “edit settings”.

Screenshot 2014-06-30 12.40.19

Choose the “VM Options” tab, expand VMware Tools, and check the “Tools Upgrades”.

Screenshot 2014-06-30 12.42.15

As you can see, this is not a convenient process to do at-scale. To perform the same commands we can update this setting on all virtual machines in the environment with four lines of code:

# This line creates the object that encapsulates the settings for reconfiguring the VM
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
# This line creates the object we will be modifying
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
# This line sets the Tools upgrades policy checkbox
$vmConfigSpec.Tools.ToolsUpgradePolicy = “UpgradeAtPowerCycle”
# This line commits the change to each virtual machine
Get-View -ViewType VirtualMachine | %{    $_.ReconfigVM($vmConfigSpec)}

If you do not wish to use a blanket upgrade script for all machines in the environment (I advise against this type of script), you can change the final line of code to the following:

Get-VM “*MGMT*” | Get-View | %{ $_.ReconfigVM($vmConfigSpec)}

This will set the VMTools update checkbox for all virtual machines that include’ ‘MGMT’ in their name. Replace ‘MGMT’ with your desired keyword or full VM name.

You can visit Luc Dekens blog HERE.

3. Report Guest-OS Disk Usage

The final script comes from Sebastian Barylo. This script creates a CSV of all the VM’s on a given datastore, the capacity, free space in Megabytes and the % free. This is helpful for admins, especially if no guest disk space monitoring is occuring in the environment. To run the script place the .PS1 in a folder of choice. Run the script from a powershell session with the following arguments ‘-vcenter <vcenter address> –datastore <chosen datastore>’. It will look something like this:

Screenshot 2014-06-30 14.50.06

Once run, there will be a CSV file created in the same folder as the script.

Screenshot 2014-06-30 14.58.24

The script will add a column for each disk it finds within a VM. This is just one of those handy house-keeping scripts that is handy to have around. To get the script and check out Sebastian’s blog post, click HERE.

SUMMARY

For all of you who have scripts of your own that you feel are useful. Post them on your blogs, twitter, and in the communities. Chances are many others are in need of a similar script. Who knows? Maybe you’ll be in next month’s Top 3 scripts. Stay Tuned!