Category Archives: powercli

If a VM has a C: drive with unallocated space guests OS customizations will fail

I didn’t find any information on this with an Internet search so I’m throwing it up here in case it helps someone else.

$> set-vm -vm somevm -OSCustomizationSpec w2k3_std_ent_x86_sp2_r2_tmpl


Proceed to configure the following parameters of the virtual machine with name 'somevm'?

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

set-vm : 10/10/2012 4:32:07 PM    Set-VM        Customization of the guest operating system 'winNetStandardGuest' is not supported in thisconfiguration. Microsoft Vista (TM) and Linux guests with Logical Volume Manager are supported only for recent ESX host and VMware Toolsversions. Refer to vCenter documentation for supported configurations.

At line:1 char:1

+ set-vm -vm qax1ftp201 -OSCustomizationSpec w2k3_std_ent_x86_sp2_r2_tmpl

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Set-VM], UncustomizableGuest

    + FullyQualifiedErrorId : Client20_ClientSideTaskImpl_ThreadProc_UnhandledException,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVM

I was getting this error after cloning a VM.  The OS customizations didn’t run automatically with the cloning and I couldn’t set it manually.  At first I thought the customizations had a problem, but this part tipped me off: Microsoft Vista (TM) and Linux guests with Logical Volume Manager are supported only for recent ESX host and VMware Tools versions.

I checked the C: partition on the VM and only 13 GB of it was partitioned on the 20 GB physical disk.  After expanding the C: with gparted (it’s win2003) the guest customization applied successfully.  I don’t know if this would happen if the D: drive or something else had unallocated space.

Copying a role from one vCenter to another

This is just the steps I did.  If you were going to do this a lot it could be put into a script/function.  Something like “Copy-VCRole -SourceVC xxx -TargetVC yyy -Role nameofrole“.  You also could kind of do source control by picking one vCenter to be the “role source server” and copy out the roles to the other vCenters from there.

  1. Connect to the vCenter that has the role you want.
  2. Save the privileges of the role you’re copying.
    1. $Role_OpsConsoleAccess = Get-VIPrivilege -Role “Ops Console Access”
  3. Connect to the vCenter you’re copying the role to.
  4. Create a new empty role.
    1. New-VIRole -Name “Ops Console Access”
  5. Add the privileges to the new role.
    1. $Role_OpsConsoleAccess | % { Set-VIRole -Role “Ops Console Access” -AddPrivilege (Get-VIPrivilege -PrivilegeItem $_.Name) }
  6. Check it.
    1. Get-VIRole “Ops Console Access” | select -expand privilegelist


Finally, a first post

I’ve been thinking about what a good first post would be, and I’ve been busy, and then I realized a week or two has gone by since I set this up.  Then I remembered my no frills philosophy.  Hopefully the syntax highlighting will work.

We have a cluster with about 45 hosts that was going to end up with 60 hosts.  Each blade chassis holds 4 blades, so one of the guys had the idea to break it into 4 clusters of 15 hosts each.  In each chassis the blade in slot 1 would be in cluster 1, slot 2 in cluster 2, and so on.  Of course, now when we’re deploying new VMs we needed to know which cluster had the least load.  This is the quickie report to show the least loaded cluster.  I don’t normally use write-host, but it was the quickest way to get the data.  Later I could integrate this into our VM deployment if it seems worthwhile.

How I used it (up arrow and enter to run it again):

write-host`nCluster`t        # Hosts`tCpuUsageMhz`tMemoryUsageMB`t# VMs`n—————`t——-`t———–`t————-`t—–; get-cluster cluster* | sort | % { $x=get-vmhost-location$_ | measure-Property cpuusagemhz,memoryusagemb -average; write-host$($_.Name)`t  $($x[0].Count)`t  $([int]$x[0].Average)`t`t  $([int]$x[1].Average)`t$((Get-VM -Location $_).Count) }

Readable version:

write-host`nCluster`t        # Hosts`tCpuUsageMhz`tMemoryUsageMB`t# VMs`n—————`t——-`t———–`t————-`t—–get-cluster cluster* | sort | % { 
    $x=get-vmhost-location$_ | measure-Property cpuusagemhz,memoryusagemb -averagewrite-host$($_.Name)`t  $($x[0].Count)`t  $([int]$x[0].Average)`t`t  $([int]$x[1].Average)`t$((Get-VM -Location $_).Count)