Using VUM Powercli for VMTools and Hardware upgrades

We recently had a need to update all of our VMtools and Hardware versions across the enterprise using Vwmare update manager.  We had a special case where we have to update only a group of servers deemed non-production prior to our weekend downtime for production.  We were able to get a VM export list and then pass that list to the cmdlets for Remediate-Inventory.  You can also do this by using custom annotations or any other type of filter you want if you need to specify an exact group of VM’s.

I would like to note that this script does reboot your virtual machines. There are ways to update tools without reboots, but in my experience when doing a large number of VM’s it is best to update and reboot immediately. So, we schedule outage windows for this effort. That being said the newer versions do not require reboots on vmware tools updates 5.1+.

We had a grouping already created so we created a text file and import that:

$vmlist = Get-Content "$vmlist.txt"

The key to the whole thing is that in addition to Powercli you need to download the VUM cmdlets.  You have to have the exact matching Powercli and VUM cmdlets to match your VUM install.  In my case I had to get the 5.0 versions.  You can get the version you need from the release notes here: http://www.vmware.com/support/developer/ps-libs/vumps/ .

We needed to be able to update both tools and hardware together.  The way you can do this is to do a search for both baselines and set them to a variable using the Get-Baseline VUM powercli cmdlet. I have already attached the baselines at the top datacenter level within VUM for this script to work.

$baselines = Get-Baseline -targettype VM  | where { $_.name.contains(Tools-or $_.name.contains(Hardware)}

Finally, we need to pass the $vmlist  variable to a foreach loop and then use the Remediate-Inventory command to invoke VUM to update the virtual machines.  I also chose to create a snapshot in case of any issues although if doing hardware you will not be able to revert.

$vmlist | % { Remediate-Inventory -Baseline $baselines -Entity $_ -GuestCreateSnapshot:$true -GuestKeepSnapshotHours 1 -RunAsync -Confirm:$false } 

There it is nice and simple! Here is the full script for any that choose to take it and modify for your needs. You could always pass a Get-VM object or whatever filter to get the list that you need.

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore- Confirm:$false

#Enter in variables
$vcenter = Read-Host "Enter Vcenter Name" 
$vmlist=Read-Host "Enter Server List Filename without extension"
#Connect to Vcenter
Connect-VIServer $vcenter
$vmlist = Get-Content "$vmlist.txt"
$baselines = Get-Baseline -targettype VM | where { $_.name.contains("Tools") -or $_.name.contains("Hardware")}

#send list to Remediat Entity
$vmlist | % { Remediate-Inventory -Baseline $baselines -Entity $_ -GuestCreateSnapshot:$true -GuestKeepSnapshotHours 1 -RunAsync-Confirm:$false }

Disconnect-VIServer -Server * -Confirm:$false
Advertisements

11 Responses to Using VUM Powercli for VMTools and Hardware upgrades

  1. Muhammad says:

    Hi Mark, really good and easy script. However, I had to make one mod to make the script work. The script errors out unless VMs are attached to the VM tools/HW upgrade baselines. I added “foreach ($vm in $vmlist) { Attach-Baseline -Entity $vm -Baseline $baselines}” and it work as expected.

    Thank you!

  2. Pingback: The Internet Fishing Trawler: vSphere vSphere vSphere Edition | Bede Carroll

  3. Ravi says:

    we can do vm’s without reboot hardware upgrade ?

  4. markdjones82 says:

    Ravi,
    Virtual Hardware upgrade requires a reboot and so does the first time on 5.1. After tools has been upgraded on 5.1 reboots are only needed for certain changes as noted in this link:

    http://blogs.vmware.com/vsphere/2013/02/clarification-on-zero-down-time-vmware-tools-uprade-in-vsphere-5-1.html

  5. Ravi says:

    mark,
    the question related with virtual machine hardware version upgrade after upgrade through powercli it’s required reboot or without reboot we can do the hardware version upgrade and not for vmtools upgrade ( like version 7 to 8 or 9)

    • markdjones82 says:

      Ravi,
      I am not quite understanding your question. You can do either hardware or tools seperately. Hardware will always require a reboot and tools should only require a reboot if they have never been updated since being on 5.1.

      Although if you have linux VM’s they do require a reboot for the new tools to be loaded into the kernel.

  6. Ravi says:

    from the vc each esx server and each switch wise (vswitch0,vswitch1) to collect the report through power cli ? ( i.e. we have with in the vC 200 esx , each esx 5 vswitch is there)

  7. Ravi says:

    how to collect unused data store lun details with powercli( i.e) storage team has been provided storage for 5 TB on 5 cluster but they forget to add storage.

  8. Ravi says:

    Get HBA WWN for Hosts using Powercli provide ps1 for each cluster wise and entire vcenter level with size

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: