SnapReminder sends e-mails to owners of snapshots
I love this script from Alan Renouf:-
[F]ind the offending snapshot, find the person who created it, get their email address from AD and send them an email reminding them of their mortal sin.
Our IndependentNonPersistent drives here prevent us from using snapshots, but I’m working on a “utilisation checking” script, that should help us cull some neglected machines and I might integrate some of Al’s AD interrogation into that.
VMware Developer CodeCentral
VMware have launched a new community site for code examples, and there’s a section on VMware vSphere PowerCLI (formerly VI Toolkit).
They seem to be picking the best scripts from the regular contributors to the forums, so it’s a good place to have a look for examples. They’re rated by users, and tend to be slightly better documented than the ones posted in the forums (which tend to be appended and amended as the thread progresses).
I/O Queues, “micro-bursting”, and Multipathing
Virtual Geek has an interesting article on VMware I/O queues, “micro-bursting”, and multipathing.
Looks intimidating at first glance, but it’s suprisingly straightforward.
Xtravirt White Paper on Storage Oversubscription Technologies
Excellent white paper from Xtravirt detailing advantages and disadvantages of linked-clones, thin-provisioning, and data-deduplication in order to pack more VMs onto your storage.
Storage Oversubscription Technologies | Xtravirt (registration required).
vSphere Evaluator’s Guide
Eric Siebert at vSphere-Land.com points out that VMware have published a 120-page vSphere Evaluator’s Guide that’s chock-full of information about the new features (including a nice little demo of PowerCLI).
Definitely worth checking out.
Cleaning up Template Names
I wrote this today to remove occurrences of the string “Tmpl” anywhere in the name of the template, and then to re-name the template with “Tmpl” as a prefix. It had a higher purpose than keeping everything nice and neat, but it’s rather specific to our environment so I won’t bother going into the details.
# Get all templates $objTemplates = Get-Template # Loop through the templates ForEach ($objTemplate in $objTemplates){ # Set the $StrInterimTemplateName variable to the template name, replacing the string "Tmpl" with an empty string $StrInterimTemplateName = ($objTemplate.Name -replace("Tmpl","")) # As the string we've just removed might be anywhere in the name, we need to replace double spaces with single $StrInterimTemplateName = ($StrInterimTemplateName -replace(" "," ")) # And also remove trailing spaces from the start, or the end of the string $StrInterimTemplateName = $StrInterimTemplateName.Trim() # Display on screen what we're doing (as the "Set-Template" with -WhatIf isn't very clear Write-Host Changing `[($objTemplate.Name)`] to `[ Tmpl $StrInterimTemplateName `] # Change the Template Name to the $StrInterimTemplateName variable preceeded by "Tmpl", uncomment the #-WhatIf if testing Set-Template -Template $objTemplate -Name "Tmpl $StrInterimTemplateName" #-WhatIf }
Despite being quite specific in it’s current form, this could easily be modified to rename virtual machines (or indeed any other PowerShell object).
While I suspect there’s a more elegant way to do this in fewer steps, it’s not particularly hacky.
VMware PowerCLI 4.0 released
I came back from a week’s holiday this morning to find that VMware PowerCLI 4.0 has been released as the successor to VI Toolkit 1.5. The jump from 1.5 to 4.0 is for version number consolidation, rather than being than indicitive of major changes.
They have however fixed one of the bugs that’s been annoying me, which is the inability to change drives to non-persistent, so I’ll need to revisit some of my old scripts from v1.0 and check that they still work.
You can download it from the community page. I’ll follow up with more information when I get a chance to investigate it fully.
Virtual Machine Blue Screen Detector
Carter Shanklin has used use of Microsoft Office Document Imaging Library (MODI) to improve Eric Sloof’s script to detect Blue Screens of Death (BSoDs); it now captures the errors and converts them to text.
From Eric’s blog:
[F]irst it captures a screenshot of a virtual machine. Secondly it uses the Toolkit Extensions to copy it to the local drive. When the PNG image is saved on the local drive, it’s converted to TIFF. The TIFF image will be used to extract the text using OCR.
It’s the kind of thing that naieve users expect computers to be able to do, but which actually turn out to be rather difficult tasks. It’s an incredible use of the various technologies involved – PowerCLI, the Toolkit Extensions, MODI and PrimalForms.
VMware’s vSphere 4 Cheat Sheet
VMware’s vSphere 4 PDF cheat sheet from boche.net.
“VMware supports 4x more guest operating systems than Microsoft. In fact, VMware supports more versions of Windows than Microsoft.”
pwned!
Check if servers in a text list exist as VMware VMs
I got handed a list of around 1000 servers today, and asked if any of them were part of our VI environment.
Rather than work through it by hand, I wrote the following script:
# Check if Servers on Text List exist on VMware # Assumes that the VM object name matches the server's DNS name # Set this to the text file containing the list of servers, one per line $strServerList = "C:\path\to\textFile.txt" # Create empty array for servers which are found $arrFoundServers = @() # Assign all of the VM objects to a variable $objVMs = Get-VM # Read the list of servers, and assign it to a variable $strServersOnList = (Get-Content $serverlist) # Loop through each VM forEach ($objVM in $objVMs){ # Loop through each server on the list forEach ($strServer in $strServersOnList){ # If the current VM object name matches the current item on the list if ($objVM.Name -Like $strServer){ # Add it to the array of found machines $arrFoundServers += $objVM } } } # Display the list of found machines $arrFoundServers
If your VM Object names do not match the DNS names on the list, then this won’t work, but I suppose you could combine this with some logic from the script I wrote to find mismatches.
