venerdì 14 marzo 2014

VMware: A PowerCLI GUI to edit VM hardware version 10

Hardware version 10 was introduced by VMware in late 2013 with ESXi 5.5. It brought several new improvements to VM capabilities like, for example, the maximum size of a single VMDK file up to 62TB au contraire to the 2TB of the hardware version 9 used in ESXi 5.0.

Despite the several indisputable improvements introduced by hardware version 10 some users pointed out some limitations in managing virtual machines adopting this hw version.

As you probably know virtual machine settings can only be modified using vSphere Web Client. Try to modify these VMs using the classic vSphere C# Client and you will incur in this message:



This limitation can be identified in VMware's strategy to soon discontinue the good 'ol vSphere C# Client and adopt the vSphere Flex Web Client as the standard tool to perform any kind of operation on the virtual infrastructure. Despite some features, like Site Recovery Manager, still require the C# Client others are only manageable through the Flex Client like the vSphere Data Protection or the brand new VSAN.

But what about changing a VM setting while a vCenter Server is unavailable? This of course results in Web Client unavailability. Or what about adding a new hard disk to a VM while in extreme hurry?

To answer first question a vCenter Server should NEVER be unavailable since by being the central point of infrastructure management its unavailability could introduce several limitations, not to mention the lack of several capabilities like DRS, vMotion, etc.

Second question instead was brought to my attention by several technicians working at my company. They simply find unbearably slow vSphere Web Client (maybe while editing VMs at customer site in late evening?) so to perform simple VM tasks like increasing CPUs, adding hard disks, etc. they tend to still use the C# Client. But as you know this is not possible for hardware version 10 VMs.

To keep a long story short I first try to encourage them to re-evaluate the Web Client and get used to use it even for the smallest things since this will be the future, but at the same time I embraced theyr cause and developed this little tool to help them to change, hopefully in a way smaller amount of time, settings for hardware version 10 virtual machines.

This tool was scripted in PowerCLI and once run will bring up a .NET like graphical user interface (GUI) from which perform all operations.



To use it you need to insert credentials to connect to a vCenter Server or directly to an host. Then you will have to select the host (in case you are connecting to a vCenter) on which is running/placed the VM you need to edit settings.Select the VM and modify vCPUs, RAM, increase disk size, or add new hardware like a new hard disk or a new network adapter.

Hardware version 10 VMs can be edited using PowerCLI in exactly the same way as for hw version 9 (or older) VMs.

The main cmdlets used in this script to edit VM settings are: 

Set-VM: Used to set many parameters of an existing VM like, for example, the amount of RAM, vCPUs, the High Availability Restart Priority, the hardware version, etc. 
Set-HardDisk: Edit Hard Disk properties/size for a specified Disk of a specified VM
New-HardDisk: Adds a new Hard Disk of a specified size to a specified VM.
Set-NetworkAdapter: Edit Network Adapter properties like wake on LAN, network to which the VM will be connected to, port group, MAC Address(*), etc.
New-NetworkAdapter: Adds a Network Adapter to a specified VM.

(*)In the code below I struggled, and failed, to find a proper way to edit MAC Address of a VM. I always got "Not a valid MAC Address or not in range..." error. Due to time limitations for article release I cannot overcame this obstacle and forced to leave in the code some lines regarding MAC changes: my bad. If you find a proper way to make it work you can also enable the MAC address editing feature.

Here's the PowerCLI code, as usual you can find it in my GitHub repository: Edit hw v10 VMs.ps1



That's all!!

6 commenti:

  1. HostileCoding,

    Nice stuff! I submitted a PR to convert this to a standalone module. Would have you have a problem if I integrated this into my administrator module in my repo https://github.com/rnelson0/powercli-modules with credit to you? I don't think I can integrate a single file from a repo easily, but I'd be glad to do so if possible.

    RispondiElimina
  2. I have tried above script to test in my environment. After entering vcenter name and credentials. it is not doing anything. i have pressed connect button 2-3 times. but not going further. look like Connect button is not working in it. can you please tell me if i am doing any mistake

    RispondiElimina
    Risposte
    1. Hi, could you please try using vcenter IP address and not vcenter FQDN? I think this could be something related to the DNS name resolution of the vcenter server.
      Thanks!!

      Elimina
  3. I'm getting "Something went wrong connecting to server!"

    I've tried both IP and FQDN. Also tried vCenter and ESXi host.

    RispondiElimina
    Risposte
    1. Import-Module "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\VMware.VimAutomation.ViCore.Cmdlets.dll"

      Elimina