PowerCLI: Update VMX Configuration Parameters (in mass)

My Virtual Infrastructure was recently audited.  As part of my preparation for said audit I needed to verify that several extra configuration Parameters were set on every VM. Nothing ground breaking, this has all been covered here, and here. So why the repost, well I’m obsessed with scaling! I don’t like doing anything that I can’t use to the nth degree. Having said that I found two simple tweaks that dramatically increased the performance of these scripts.

If you ever find yourself using where-object move back up the pipeline… can you use a filter instead? Here I dramatically improved performance by leveraging the built-in filter capabilities of Get-View. I was also able to crank it up by simply switching from the ReconfigVM method to the ReconfigVM_Task method. Unless your performing some serial action, always, always use the task method. Offloading the babysitting to vCenter just makes sense! Finally, I loath text files, especially when they create a needless dependencies. Here I use a simple hashtable to embed my configuration in the script it self.

I successfully used this script to update over 500 vm’s in less than 4min!  Now that is what I call scale!  I know the security experts our there would argue that this is meaningless, b/c of this or that… all I know is I passes my audit with flying colors (didn’t have one ding on a VM’s configuration).

~Glenn

6 thoughts on “PowerCLI: Update VMX Configuration Parameters (in mass)

  1. I altered this just slightly to set all the options in for the Enterprise level of VMware’s hardening guide.

    $ExtraOptions = @{
    #VMX01
    “isolation.tools.diskShrink.disable”=”true”;
    “isolation.tools.diskWiper.disable”=”true”;
    #VMX03
    “isolation.tools.copy.disable”=”true”;
    “isolation.tools.paste.disable”=”true”;
    “isolation.tools.setGUIOptions.enable”=”false”;
    #VMX11
    “isolation.device.connectable.disable”=”true”;
    “isolation.device.edit.disable”=”true”;
    #VMX12
    “vmci0.unrestricted”=”false”;
    #VMX20
    “log.keepOld”=”10”;
    “log.rotateSize”=”1000000”;
    #VMX21
    “tools.setInfo.sizeLimit”=”1048576”;
    #VMX30
    “guest.command.enabled”=”false”;
    #VMX31
    “tools.guestlib.enableHostInfo”=”false”
    }

  2. Hello Glen,

    What a super script!

    But I guess, after running this script, we still need to powerOff / powerOn the virtual machines to make these options effective ?

    Regards,
    Harold

Leave a Reply