VMware Cloud Community
RyanMcL
Enthusiast
Enthusiast
Jump to solution

OSCustomizationSpecImpl to CustomizationSpec

$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec

$cloneSpec.Customization = Get-OSCustomizationSpec -Name "Windows Server Default"

results in:

Exception setting "Customization": "Cannot convert the "Windows Server Default" value of type "VMware.VimAutomation.ViCore.Impl.V1.OSCustomization.OSCustomizationSpecImpl" to type "VMware.Vim.CustomizationSpec"."

Anyone know how can I convert between the types?

Regards,

Ryan

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can't assign a .Net object to a property that expects a server-side object.

You can do this

$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec 
$cloneSpec.Customization = (Get-OSCustomizationSpec -Name "Windows Server Default").ExtensionData.Spec


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You can't assign a .Net object to a property that expects a server-side object.

You can do this

$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec 
$cloneSpec.Customization = (Get-OSCustomizationSpec -Name "Windows Server Default").ExtensionData.Spec


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RyanMcL
Enthusiast
Enthusiast
Jump to solution

Thanks LucD!

And in return here is the fruits of my labour. http://ninet.org/2011/11/clone-vmfromsnapshot/ It is a script to create a clone from a specific snapshot.

Regards,

Ryan

0 Kudos