One of the exciting new dvSwitch features in vSphere 5.1 is the ability to export and restore a dvSwitch configuration. This new feature is only available through the vSphere Web Client.
On Hypervisor.fr, a blog you should have in your RSS reader, there were already posts on how to configure the dvSwitch healthcheck and how to do a dvSwitch configuration rollback from PowerCLI. But till now, as far as I know, there were no functions to provide the dvSwitch export/restore functionality.
Time to make this useful functionality available for the “PowerCLI automation crowd” 😉
Continue reading dvSwitch scripting – Part 13 – Export/Restore Config
One of the hot new features in vSphere 5 was the introduction of SDRS. And with SDRS came the concept of affinity rules for VMs and VMDKs. Cormac, aka @VMwareStorage, posted a nice overview of the SDRS affinity rules in Storage DRS Affinity & Anti-Affinity Rules.
Since then several posts have appeared on the subject of SDRS affinity rules. To list just a few:
Currently there are no PowerCLI cmdlets to define the inter- and intra-vm anti-affinity rules for SDRS. After a question in the VMTN PowerCLI Community I decided to write a function. This function will allow you to automate the creation of the SDRS anti-affinity rules.
Continue reading Automate your SDRS Anti-Affinity rules
Another post that comes from a VMTN PowerCLI Community question. Jeff wanted to find the free SCSI LUNs in his environment.
While answering that thread I was amazed there was no PowerCLI function written yet to provide this functionality. At least that was what my friend Google told me 😉
Since there exists a SDK method that makes retrieving free SCSI LUNs quite easy, the function I came up with isn’t too complex.
But it should help you in further automating the setup of your datastores.
Continue reading Find free SCSI LUNs
The end of the year is near again. Time to plan for the new, but also a time to look back on what was there in the past year.
Your vSphere environment is no different. It is time to produce some of those dreaded year reports that will show you how your environment has been doing. And one of the aspects a lot of people are very keen about, is the number 9 game 😉
What was the uptime of the VMs you had running ?
The question popped up on several occasions in the PowerCLI Community as well. So I guess I was not the only one that was looking for a way to calculate the uptime of Virtual Machines.
Bug alert ?: it seems that the PerformanceManager handles vMotions in a strange way. After a vMotion the sys.uptime.latest is reset to 0 (zero). That is understandable, since the VM is now running on a different ESXi host. But it seems that the aggregated metric do not add up all the sys.uptime.latest metrics from different ESXi hosts. So when you use DRS or do vMotions yourself, the produced report will have some serious flaws !
Continue reading Game of Nines – VM Uptime Report
In a recent thread on the VMTN PowerCLI Community someone asked if it is possible to get historical hard disk statistics. I referred the user to my Datastore usage statistics post, where I showed how to use the “disk” metrics to get that information.
But getting the individual vDisk statistics is a bit more tricky compared to getting the datastore statistics, as I showed in that post. The “disk” metrics hold the information, but the Instance that points to the MoRef value of a VM makes it a bit more tricky to retrieve.
Be forewarned, the “disk” metrics hold usage data for all the vDisks that a specific VM has on a specific datastore. You will not be able to get individual vDisk statistics, unless the vDisks are stored on different datastores !
On the positive side, the “disk” metrics will allow you to see how your vDisks increase in size over time. For your Thick vDisks that increase will be by expanding them, and for your Thin vDisks it will also show the natural growth.
Continue reading Monitor the size of your vDisks
Now that Windows 8 and Windows Server 2012 are readily available , we all want to do some exploring. But if you want to automate the creation of some test VMs for this, you are in for a surprise.
The current PowerCLI 5.1 Release 1 doesn’t accept the E1000E NIC as a Type on the New-NetworkAdapter cmdlet. Users start hitting this limitation, as can be seen on this PowerCLI Community thread. You can go for the E1000, but why settle for less if you can easily script the use of the E1000E NIC from PowerCLI?
So even though Eric “the Scoop Meister” Sloof debunked the myth that the E1000/E1000E is faster than the VmxNet3, the E1000E is the default NIC type that vSphere gives you when you create a VM for a Windows Server 2012 or Windows 8 VM. Note that the E1000 apparently uses slightly more CPU resources than the E1000E. With the function in this post you can now automate this behavior.
Update November 17th 2012: In KB2006859 it seems to say that the VMXNET3 NIC doesn’t work with Windows Server 2012 or Windows 8. And there have been several blogs (including mine) that picked up this info. But after you apply the September 2012 patch to your ESXi servers, you can also use a VMXNET3 NIC for both Windows OS. See here and here for more info.
Thanks to reader alcapapower for drawing my attention to this (see his remark in the comments below).
Continue reading Work with E1000E NICs in PowerCLI
The VMTN PowerCLI Community is a constant source of inspiration for blog posts. User roswellevent raised, in the thread Any way to get virtual machine Nic card usage?, the question if it was possible to get the transmit and receive rate for each vNIC in virtual machines.
Since I’m interested in all things statistics in vSphere I decided to tackle the question. Finding the metrics to use for this kind of report is not too difficult. Under the PerformanceManager Network section we find the metrics net.received.average and net.transmitted.average. And, provided your Statistics Level is set to 3 for the timeframe you want to report on, the metrics capture statistics on the device level.
Great, exactly what we need! A quick check in the Performance tab in the vSphere Client showed an additional problem to solve. The instance didn’t mention Network Adapter 1 but a number.
Continue reading vNIC transmit and receive rates
Lately I have been playing around with the new Storage related features in vSphere 5. One of the novelties is that you can now unmount a VMFS datastore and detach a SCSI LUN through the API.
To be able to unmount a datastore, some conditions have to be met. In the vSphere Client you get an informative popup that tells what is prohibiting the datastore unmount. If not all conditions are met, you can not continue with the unmount.
Nice feature, but what for those of us that want to automate this ?
Update October 28th 2012: Take into account that the datastorecluster is not connected to a host that is part of a cluster. Skip the HA heartbeat test.
Update April 23th 2012: Use the RetrieveDasAdvancedRuntimeInfo method to find the actual datastores that are used for the heartbeat.
Continue reading Test if the datastore can be unmounted
On the PowerCLI Community there was an interesting question about dvSwitches, portgroups and connecting VMs. Turns out you will need to provide a free port to connect a VM’s NIC to a portgroup on dvSwitch.
Since the solution is a nice follow up on my previous, somewhat lengthy post, called Variations on a port, I decided to create a short post on the subject in my dvSwitch series.
Update 3th March 2016: added test to capture portgroups with no VM connected to it
Continue reading dvSwitch scripting – Part 12 – Find free ports
I got an interesting question from one of my co-authors of the PowerCLI Reference book. He was looking for a method to find the port used by a VM when connected to a portgroup on a dvSwitch.
Finding the answer to that question is not too difficult, once you know which property holds the value. But while writing and testing the script, I thought that this question would be a good opportunity to show several ways and methods that you have at your disposal in PowerCLI and PowerShell, to come to a solution.
Here it goes.
Continue reading Variations on a port