Setting custom attributes with VMware PowerCLI

Last week I wanted to extend my vCenter with some extra custom attributes on my VMs. This would extend the usability of the Export List feature for reporting purposes. So together with Hal Rottenberg’s “Managing VMware Infrastructure with Windows PowerShell TFM” book in my hand, I took a dive into VMware PowerCLI (formerly known as the VI Toolkit for Windows).

Creating the script that would do this task wasn’t so difficult at all, but I quickly ran into a problem were the single cmdlet “Set-CustomField” for setting the custom attribute took a rather long time to complete. In my production environment updating one custom attribute took 70 seconds!. Since I wanted to update 4 custom attributes on each VM this script would run for ages. Doing some quick calculations:
4 custom attributes * 842 VMs * 70 seconds = 235760 seconds = 65,48 hours!

At that point I received a message from Luc Dekens if I would be interested in testing a faster solution than using the “Set-CustomField” cmdlet. Offcourse I was Interested and started off to try Luc’s approach on my environment. Results were amazing. Luc’s code updated a single custom attribute in 500 milliseconds!. This would mean for me:
4 custom attributes * 842 VMs * 0.5 seconds = 1684 seconds = 28,06 Minutes!

This is 142 times faster and an improvement of 14200% in my environment. Well that’s something worth looking for.

If you are interested in changing custom attributes in PowerCLI, you definitely MUST read Luc’s post PowerCLI on steroids – Custom attributes

Related posts:

  1. Bulk change your ESX root password Tweet Have you ever been facing your security department demanding you to change your ESX root password? Well I did. At the current site there’s a strict security policy where...

0 Comments on “Setting custom attributes with VMware PowerCLI”

Leave a Comment