vSphere Snapshot Report

I have been working on addressing a comment I noticed on the Virtu-Al vCheck comments (http://www.virtu-al.net/featured-scripts/vcheck/). The issue relates to a warning message returned in the “checking snapshots” section:

10:58:25 AM ..Checking Snapshots
WARNING: Unable to populate snapshot size due to unsiffucient permissions.

The existing code worked for me (I did not receive the above warning in any of my environments). The problem may be related to the version of PowerCLI [version 4.1 U1 build 332441 appears to work well]. The snapshot code inside vCheck is fairly complex, and I had some trouble following what was happening. After a few minutes of trying to following along I gave up and tried to write the same thing a different way. Here is the modified section that can be ran independently…troubleshootSnapshots.ps1

I’m looking for testers (again). If this code works for you, please let me know. If this code proves to work better I’ll update my version of vCheck to include the new method.

Posted in Scripting, Virtualization | Leave a comment

2011 Governor’s Public Service Achievement Award

In the world of scripting and automation I find it easy to get lost in technical requirements and code while forgetting the reason people automate tasks — improved accuracy and cost savings. Earlier this week my co-workers and I were reminded of these reasons. Our team was recognized with the Indiana 2011 Governor’s Public Service Achievement Award.


From left to right: Tony Lewis, Clayton Molnar, Governor Mitch Daniels, Brian Wuchner, Bob Clarke

Being recognized at this level was a great honor for our team. Now we are energized and ready to find new and exciting ways to improve accuracy and decrease costs.

Enough with patting myself on the back…it is time to code! I’m working on yet another vSphere snapshot report script which should be posted in a day or two…stay tuned.

Posted in Scripting | Leave a comment

Windows Disk Partition Alignment Best Practices

I was recently sent the following link that describes disk partition alignment best practices for SQL Server:

http://msdn.microsoft.com/en-us/library/dd758814.aspx

This is a really good article — it describes the performance implication of mis-aligned drives — which apply to all Windows installs, not just SQL servers. I’ve participated in alignment discussions several times — specifically as it relates to virtual machine disks. What I like about this article and the ‘performance impact’ section is the test description. The results are not VMware or SAN/array specific — they relate to local disk (SAS DAS). The issue of alignment is not a VMware discussion — it is primarily a Windows OS discussion.

Posted in Virtualization | Leave a comment

Free VMware Transition to ESXi Essentials course

I recently completed the free VMware Transition to ESXi Essentials course. If you’d like more information on how to sign up for this course yourself, check out the following link: http://blogs.vmware.com/esxi/2011/04/become-a-true-esxi-expert-with-the-new-free-vmware-elearning-course-and-ebook-offer.html

I wanted to share a few specific things I learned from the training. If the price tag (free) isn’t enough to entice you to sign up, hopefully the following details will.

Module 4 of the training discusses using the vMA and goes into specific detail on vifp addserver, mcli.pl and vicfg-hostops. I’ve used one of these commands before, but learned something about it; the other two commands were new to me — but I’m sure I’ll be using them soon.

vifp addserver: I’ve used this command several times before. Once you have servers added with fastpass, you can issue commands to the host without providing credentials. What I didn’t realize, but learned from the course, is that vifp addserver creates local accounts on the ESXi host. I verified that several of my ESXi hosts still have these users hanging out.

mcli.pl: located in /opt/vmware/vma/samples/perl; allows running the exact same command against a list of ESXi host names. I have not tried yet, but I would assume this could be used to enable CDP for a virtual switch on all hosts in a cluster (see http://enterpriseadmins.org/blog/virtualization/update-to-enabling-vswitch-cdp-vma-4-1/ for CDP syntax)

vicfg-hostops: allows hosts to be put into maintenance mode (with -o enter) or removed (with -o exit) from within the vMA. This would be helpful when using vihostupdate to deploy a bundle. Normally I turn this into a 2 console operation…now I can do it all from the command line!

This module also shared the link to a PDF worth keeping around — vSphere Command-Line Interface Installation and Scripting Guide.

This is just a sample of the ~3 hours worth of quality content. I’d recommend any VMware administrator find the time to sit through this eCourse presentation.

Posted in Virtualization | 1 Comment

Migrate virtual machines and enable thin provisioning

I recently used this code to move a couple dozen terabytes of virtual machines from one array to another — all while enabling thin provisioning (aka sparse disk). Once the LUN migration is complete a nice little message shows up in your email. It is a very straight forward script that I thought was worth sharing.


$startTime = get-date
$sourceDS = "array1-1000"
$destDS = "array2-3000"

$dsView = Get-Datastore -Name $destDS | Get-View -Property Name

Get-VM -Datastore $sourceDS | sort name | % {
	$vmView = $_ | Get-View -Property Name
	$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
	$spec.datastore =  $dsView.MoRef
	$spec.transform = "sparse"
	$vmView.RelocateVM($spec, $null)
}

Send-MailMessage -From "vmware@mydomain.local" -SmtpServer "smtp.mydomain.local" -Subject "Migration from $sourceDS to $destDS complete" -To "me@mydomain.local" -BodyAsHtml "This task started at $($startTime.datetime.tostring()) and finished at $((get-date).datetime.tostring())"
Posted in Scripting, Virtualization | 1 Comment