Did you post the source you're using to manipulate the CustomizationSysprep? I see a lot of
other code in that thread (which is greatly appreciated, BTW), but not that.
I did this a few years back, but in Java (using VI Java). I don't have access to that source anymore,
but it looked something like this:
if (identity instanceof CustomizationSysprep) { CustomizationSysprep winIdentity = (CustomizationSysprep) identity; CustomizationName name; if (hostName != null) { CustomizationFixedName fname = new CustomizationFixedName(); fname.setName(hostName); name = fname; }else{ name = new CustomizationVirtualMachineName(); } winIdentity.getUserData().setComputerName(name); }
The trick is that UserData.computerName takes an object, not a name directly.
So if I had a "hostName" string, I used that as the computer name (via CustomizationFixedName), otherwise
I let vSphere name it based on the VM name (via CustomizationVirtualMachineName).
Hope this helps.