View Only
Expand all | Collapse all

Deploy VM from template using CloneVM_Task

  • 1.  Deploy VM from template using CloneVM_Task

    Posted Jul 02, 2009 06:05 PM

    I am trying to create a script that will deploy a VM from a template using the CloneVM_Task customization. Eventually I want to be able to deploy dozens of VMs from one template very quickly but first I am trying this out on one VM. I just can't seem to get it working. I used a script from and

    After I run the script in PowerCLI I view the progress in vSphere Client. The VM is created and the Clone Virtual Machine task gets to 93% at which time the task viewer says it is "Customizing the new Virtual Machine." That's about when the vCenter server crashes and when it comes back up again I can see in the task viewer that the Clone Virtual Machine task failed with an "Error."

    I attached the script I am using below, any ideas?

  • 2.  RE: Deploy VM from template using CloneVM_Task

    Broadcom Employee
    Posted Jul 02, 2009 06:37 PM

    When I see an error like this, it is generally related to the OS Customization spec, or not having the appropriate sysprep tools installed on the vCenter server.

    As a test, can you deploy VMs via your script without customizing the OS? That will at least narrow the problem. I like to use New-VM with the Template option...

    new-vm -template `
    (get-template "My-Template") `
    -name "Name-of-new-VM" `
    -host (get-vmhost name-of-target-host) `
    -location (get-folder –name "My Folder") `
    -pool (get-resourcepool "My Resource Pool") `
    -Datastore (get-datastore "My-Datastore-1")

  • 3.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 02, 2009 07:43 PM

    Okay I tried deploying without customization using new-vm and things worked fine. I don't think that there is a sysprep issue because I can customize VMs when I deploy using a customization specification through the vSphere Client GUI. Thanks for your help, it sounds like this is an issue with the syntax of the customization in my script. I'm not sure what is wrong, because other people seem to use this script with no problems.

  • 4.  RE: Deploy VM from template using CloneVM_Task

    Broadcom Employee
    Posted Jul 02, 2009 08:05 PM

    That's a helpful error message :>

    So, your vCenter server actually goes down??

    I'm with Luc... check your sysprep utilities. Can you deploy and customize the same VM template using similar custom spec settings via the GUI w/o VC going down?

  • 5.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 02, 2009 11:33 PM

    Upon close inspection, the vCenter services go down, not the server itself. During the customization of the new VM, the processor and memory utilization on the vCenter server peak before the vCenter services stop. Several minutes later they start up again, so it looks like vCenter is crashing and not the server itself.

    I have the latest version of the files on vCenter server in the sysprep folder. I can deploy from this same template using similar configuration using the GUI with no problems.

    I keep thinking maybe there is one thing wrong in the script causing this problem that I need to change, but I'm not an expert in powershell.

  • 6.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 03, 2009 08:19 AM

    Checked the script you are using and there is one error in there around line 38.


    #setup resource pool
    $pool = get-resourcepool -id $vmpool

    should be

    #setup resource pool
    $pool = get-resourcepool $vmpool


    I'm not sure why you get no error message on this.

    From where are you running the script ?

    Could it be that you have ErrorAction set to silentlycontinue ?

    In any case, when I corrected that line the script ran without a problem (and the template was cloned).

  • 7.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 09, 2009 05:15 PM

    I changed this part of the script and vCenter still crashes. I have even tried another similar script from RobMokkink and I have the same problem. I am using PowerCLI 4.0 and vSphere 4.0, not sure if there are incompatibility issues with the version used to create the scripts if they are different.

    I wonder if this has something to do with the configuration of vCenter. Was something missed when it was installed and set up? I also noticed that the vCenter Server only has 2GB of RAM while VMware recommends 3GB of RAM. And the database is running on the server. Could this be the problem? I can deploy virtual machines from templates using the vSphere Client, I can deploy virtual machines using a script pointing to a customization specification, I just can't deploy from a script where I specify the customization variables in the script.

  • 8.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 09, 2009 07:40 PM

    I was looking through the log just before vCenter crashed and found this error labeled "panic." A couple seconds later the log ends and the server crashes. Could this be the problem?

    2009-07-08 14:03:16.023 05616 verbose 'App'] Setting param LicenseFilePrintData.AutoMode to value perSeat

    2009-07-08 14:03:16.023 05616 verbose 'App'] Added nic setting cmd guestcustutil.exe setupNic -m 00:50:56:80:58:2c -s -su -g -gm 1 -d -t 0

    2009-07-08 14:03:16.023 05616 info 'App'] Successfully created directory C:\Windows\TEMP\imc-10

    2009-07-08 14:03:16.023 05616 verbose 'App'] Sysprep output dir: C:/Windows/TEMP/imc-10, verify unattended: true

    2009-07-08 14:03:16.054 04784 verbose 'App'] Invoke done: vmodl.query.PropertyCollector.waitForUpdates session: 7A6D3A2C-C1B4-4B02-866C-C3854C376E03

    2009-07-08 14:03:16.054 05616 error 'App'] Win32 invalid_parameter: expression=(null), function=(null), file=(null), line=0

    2009-07-08 14:03:16.070 04784 verbose 'SoapAdapter.HTTPService'] HTTP Response: Complete (processed 71331 bytes)

    2009-07-08 14:03:16.132 05616 error 'App']

    Panic: Win32 invalid_parameter error


    backtrace00] eip 0x01fe88f0 ?AbortProcess@System@Vmacore@@YAXXZ

    backtrace01] eip 0x01fe9077 ?CreateBacktrace@SystemFactoryImpl@System@Vmacore@@UAEXAAV?$Ref@VBacktrace@System@Vmacore@@@3@@Z

    backtrace02] eip 0x01f2b863 ?PanicExit@Vmacore@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z

    backtrace03] eip 0x01ff8a70 ?GetThisThread@System@Vmacore@@YAPAVThread@12@XZ

    backtrace04] eip 0x73c48aa0 invalidparameter_noinfo

    backtrace05] eip 0x6d839faf ?NonLonghornFlush@SysprepConfigGenerator@GuestCust@@AAEXABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem@boost@@@filesystem@boost@@_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@7@1@Z

    backtrace06] eip 0x6d83ac23 ?Flush@SysprepConfigGenerator@GuestCust@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N0AAV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@4@1@Z

    backtrace07] eip 0x005eac40 (no symbol)

    backtrace08] eip 0x005ef182 (no symbol)

    backtrace09] eip 0x00b69e9c (no symbol)

    backtrace10] eip 0x00b6baac (no symbol)

    backtrace11] eip 0x00b6bd40 (no symbol)

    backtrace12] eip 0x00b16be5 (no symbol)

    backtrace13] eip 0x00b18220 (no symbol)

    backtrace14] eip 0x0076678f (no symbol)

    backtrace15] eip 0x02393e53 ??4ScheduledTaskManager@Scheduler@Vim@@QAEAAV012@ABV012@@Z

    backtrace16] eip 0x021937ab ?AddFat@Activation@Vmomi@@QAEXPAVObject@Vmacore@@@Z

    backtrace17] eip 0x02193782 ?AddFat@Activation@Vmomi@@QAEXPAVObject@Vmacore@@@Z

    backtrace18] eip 0x0082b583 (no symbol)

    backtrace19] eip 0x0080bbd9 (no symbol)

    backtrace20] eip 0x00814777 (no symbol)

    backtrace21] eip 0x00821c31 (no symbol)

    backtrace22] eip 0x00d1f758 (no symbol)

    backtrace23] eip 0x777c4911 BaseThreadInitThunk

    backtrace24] eip 0x77bbe4b6 RtlInitializeExceptionChain

    backtrace25] eip 0x77bbe489 RtlInitializeExceptionChain

    2009-07-08 14:03:16.460 03528 verbose 'App'-- Entity has been relocated: vm-401

    2009-07-08 14:03:16.569 04784 verbose 'SoapAdapter.HTTPService'-- User agent is 'Jakarta Commons-HttpClient/3.1'

  • 9.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 09, 2009 08:04 PM

    I think you better open a call with VMware for this problem.

    It's way beyond what I have ever seen.

  • 10.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 02, 2009 07:46 PM

    Do you have the sysprep binaries copied to your Virtual Center server ?

    And are they the correct version ?

    See Appendix B in vSphere Basic System Administration for further info.

  • 11.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 27, 2009 07:19 PM

    Hi, i got exactly the same issue since i updated the vcenter server from 2.5 U4 to 4.0

    Since the update, i was using the RobMokkin's script almost every day !

    The vcenter service crash during the customization guest too :

    -- FINISH task-internal-64967 -- host-1006 -- VpxdInvtHostSyncHostLRO.Synchronize --

    hostVersion = 3.5.0, tools version = 7302

    hostVersion = 3.5.0, tools version = 7302

    Sysprep options: -quiet -mini -reseal -reboot

    Successfully created file C:\WINDOWS\TEMP\imcEB.tmp

    Successfully created directory C:\WINDOWS\TEMP\imc-2

    Win32 invalid_parameter: expression=(null), function=(null), file=(null), line=0

    Panic: Win32 invalid_parameter error


    backtrace[00] eip 0x019e88f0 ?AbortProcess@System@Vmacore@@YAXXZ

    backtrace[01] eip 0x019e9077 ?CreateBacktrace@SystemFactoryImpl@System@Vmacore@@UAEXAAV?$Ref@VBacktrace@System@Vmacore@@@3@@Z

    backtrace[02] eip 0x0192b863 ?PanicExit@Vmacore@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z

    backtrace[03] eip 0x019f8a70 ?GetThisThread@System@Vmacore@@YAPAVThread@12@XZ

    backtrace[04] eip 0x78138aa0 invalidparameter_noinfo

    backtrace[05] eip 0x10019faf ?NonLonghornFlush@SysprepConfigGenerator@GuestCust@@AAEXABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem@boost@@@filesystem@boost@@_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@7@1@Z

    backtrace[06] eip 0x1001ac23 ?Flush@SysprepConfigGenerator@GuestCust@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N0AAV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@4@1@Z

    backtrace[07] eip 0x005eac40 (no symbol)

    backtrace[08] eip 0x005ef182 (no symbol)

    backtrace[09] eip 0x00b69e9c (no symbol)

    backtrace[10] eip 0x00b6baac (no symbol)

    backtrace[11] eip 0x00b6bd40 (no symbol)

    backtrace[12] eip 0x00b16be5 (no symbol)

    backtrace[13] eip 0x00b18220 (no symbol)

    backtrace[14] eip 0x0076678f (no symbol)

    backtrace[15] eip 0x01d93e53 ??4ScheduledTaskManager@Scheduler@Vim@@QAEAAV012@ABV012@@Z

    backtrace[16] eip 0x01b937ab ?AddFat@Activation@Vmomi@@QAEXPAVObject@Vmacore@@@Z

    backtrace[17] eip 0x01b93782 ?AddFat@Activation@Vmomi@@QAEXPAVObject@Vmacore@@@Z

    backtrace[18] eip 0x0082b583 (no symbol)

    backtrace[19] eip 0x0080bbd9 (no symbol)

    backtrace[20] eip 0x00814777 (no symbol)

    backtrace[21] eip 0x00821c31 (no symbol)

    backtrace[22] eip 0x00d1f758 (no symbol)

    backtrace[23] eip 0x7c826063 GetModuleFileNameA

    CoreDump: Writing minidump

    LucD, you're our only hope -in the galaxy :smileywink:

  • 12.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 27, 2009 07:32 PM

    I just see a difference betwen the vcenter 2.5 and 4.0 customSpec export :



    But, according to this doc, this parameter is not mandatory.

  • 13.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 27, 2009 11:45 PM

    Here is what apears in vpxd.log when everything's good :

    Successfully created directory C:\WINDOWS\TEMP\imc-7

    Create sysprep file package. Params:

    file = C:\WINDOWS\TEMP\imc18.tmp

    binary dir = C:\Program Files\VMware\Infrastructure\VirtualCenter Server\

    options = -quiet -mini -reseal -reboot

    config = C:\WINDOWS\TEMP\imc-7

    sysprep = C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\svr2003

    tools =

    native =

    nativeArgs =

    Successfully created file C:\WINDOWS\TEMP\imc19.tmp

    Creating cab file imc19.tmp

    Adding C:\Program Files\VMware\Infrastructure\VirtualCenter Server\guestcustutil.exe as guestcustutil.exe

    Adding C:\Program Files\VMware\Infrastructure\VirtualCenter Server\imgcust-reboot.exe as imgcust-reboot.exe

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\bootrun.exe as sysprep\i386\$OEM$\bootrun.exe

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\bootrunMsg.dll as sysprep\i386\$OEM$\bootrunMsg.dll

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\cmdlines.txt as sysprep\i386\$OEM$\cmdlines.txt

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\finalizationsetup.bat as sysprep\i386\$OEM$\finalizationsetup.bat

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\finalize.bat as sysprep\i386\$OEM$\finalize.bat

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\guestcustutil.exe as sysprep\i386\$OEM$\guestcustutil.exe

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\imgcust-reboot.exe as sysprep\i386\$OEM$\imgcust-reboot.exe

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\imgres\de\loginblockerRes.dll as sysprep\i386\$OEM$\imgres\de\loginblockerRes.dll

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\imgres\ja\loginblockerRes.dll as sysprep\i386\$OEM$\imgres\ja\loginblockerRes.dll

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\imgres\zh-CN\loginblockerRes.dll as sysprep\i386\$OEM$\imgres\zh-CN\loginblockerRes.dll

    Adding C:\WINDOWS\TEMP\imc-7\i386\$OEM$\loginblocker.exe as sysprep\i386\$OEM$\loginblocker.exe

    Adding C:\WINDOWS\TEMP\imc-7\sysprep.inf as sysprep\sysprep.inf

    Adding C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\svr2003\setupcl.exe as deploy\setupcl.exe

    Adding C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\svr2003\sysprep.exe as deploy\sysprep.exe

    Adding C:\Program Files\VMware\Infrastructure\VirtualCenter Server
    sysprepDecrypter.exe as sysprepDecrypter.exe


    Added file guestcustutil.exe

    Added file imgcust-reboot.exe

    Added file sysprep\i386\$OEM$\bootrun.exe

    Added file sysprep\i386\$OEM$\bootrunMsg.dll

    Added file sysprep\i386\$OEM$\cmdlines.txt

    Added file sysprep\i386\$OEM$\finalizationsetup.bat

    Added file sysprep\i386\$OEM$\finalize.bat

    Added file sysprep\i386\$OEM$\guestcustutil.exe

    Added file sysprep\i386\$OEM$\imgcust-reboot.exe

    Added file sysprep\i386\$OEM$\imgres\de\loginblockerRes.dll

    Added file sysprep\i386\$OEM$\imgres\ja\loginblockerRes.dll

    Added file sysprep\i386\$OEM$\imgres\zh-CN\loginblockerRes.dll

    Added file sysprep\i386\$OEM$\loginblocker.exe

    Added file sysprep\sysprep.inf

    Added file deploy\setupcl.exe

    Added file deploy\sysprep.exe

    Added file sysprepDecrypter.exe

    Successfully deleted file/directory C:\WINDOWS\TEMP\imc19.tmp

    Successfully deleted file/directory C:\WINDOWS\TEMP\imc-7

    Can anyone post the same thing with vcenter 2.5 to compare ? Thx :smileywink:

  • 14.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 05:53 AM

    Like I said before, I'm afraid this is beyond me.

    I think you better open a call for this.

    The only difference I can see is that in the vSphere API 4.0 the VirtualMachineCloneSpec object has a new property, called snapshot, which wasn't there in the VI API 2.5 VirtualMachineCloneSpec object.

  • 15.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 06:19 AM

    My P.I. is already testing the script. Since i don't have my vSphere lab up and running at work :smileywink:

  • 16.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 07:41 AM

    My P.I. had the same problems. vCenter server services crashes when the clone reaches 97%.

    I looked at the snapshot option, but that is not a required option.

    Maybe it is a bug :smileywink:

  • 17.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 08:00 AM

    True, it's not a required parameter but the total number of parameters for the method changed.

    I strongly suggest to open a support call :smileywink:

  • 18.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 10:11 AM

    Hi LucD,

    Thanks for your answer, before calling the support can you tell me where i can search (if it's not )

    Edit : seen here

    New privilege Datastore.AllocateSpace.

    The new privilege


    to the following previously-existing methods:

    * Folder.CreateVM_Task

    * VirtualMachine.CloneVM_Task

    * VirtualMachine.ReconfigVM_Task

    * VirtualMachine.RelocateVM_Task

    * VirtualMachine.CloneVM_Task

    and here is the SDK ReferenceGuide :

  • 19.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 12:29 PM

    i Might found something :

    vCenter Server Issues

    <!-- 28-apr-2009; bug 382167 -->

    vCenter Server Does Not Handle Errors Properly for diskMoveType Property of VirtualMachineRelocateSpec

    The <code>diskMoveType</code> property of the <code>VirtualMachineRelocateSpec</code> data object must contain one of the <code>VirtualMachineRelocateDiskMoveOptions</code> enumerations. If you set the value of <code>diskMoveType</code>

    to anything other than one of these enumerations, the vCenter Server

    does not notify you of the error and instead, might set the <code>diskMoveType</code> to <code>moveAllDiskBackingsAndAllowSharing</code>. Depending upon your specific use case, this disk type might be inappropriate. When creating a <code>VirtualMachineRelocateSpec</code> (for use with <code>CloneVM_Task</code> or <code>RelocateVM_Task</code> operations) set the <code>diskMoveType</code> to the proper value from the <code>VirtualMachineDiskMoveOptions</code> enumerated type.

    See the vSphere API ReferenceGuide for information about the VirtualMachineRelocateDiskMoveOptions enumerated type.

  • 20.  RE: Deploy VM from template using CloneVM_Task
    Best Answer

    Posted Jul 28, 2009 01:15 PM

    I found !!!!!!!!!!!

    removing VMware.Vim.CustomizationGuiRunOnce object and it works :

    #$vmcSpec.Customization.Identity.guiRunOnce = New-Object VMware.Vim.CustomizationGuiRunOnce

    #$vmcSpec.Customization.Identity.guiRunOnce.commandList = $RunOnce

  • 21.  RE: Deploy VM from template using CloneVM_Task

    Posted Jul 28, 2009 01:53 PM

    I looked at the SDK but there is no difference between version 2.5 and vSphere.

    What needs to be changed so guirunonce can be specified?