Automation

 View Only
Expand all | Collapse all

copy OSCustomizationSpec to another vcenter

  • 1.  copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 12:49 PM

    Hi,

    i'm trying to copy the existing Customization Specs from one vcenter to another.

    Connect-VIServer -Server vc-old -Port 443 -Protocol https

    Connect-VIServer -Server vc-new -Port 443 -Protocol https


    $CUSTSPECS = Get-OSCustomizationSpec -Server vc-old


    foreach ($CUSTSPEC in $CUSTSPECS) {
                                  New-OSCustomizationSpec -OSCustomizationSpec $CUSTSPEC -Name $CUSTSPEC.Name -Server vc-new
                    }

    I get the following error:

    New-OSCustomizationSpec : New-OSCustomizationSpec An OSCustomizationSpec with the same name already exists on the server.

    New-OSCustomizationSpec ignores the "-Server" option and tries to create the spec on the vc-old vcenter. Can i solve this problem without exporting the specs?

    Thanks for any feedback!



  • 2.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 12:52 PM

    Did you try closing vc-old explicitely (disconnect-VIServer) before doing the New-OSCustomizationSpec ?



  • 3.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 12:59 PM

    Hi LuCD,

    i also tried to close the vc-old connection, but then the object is invalid.



  • 4.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 01:12 PM

    I think that is because the Server and ServerId properties of the OSCustomizationSpecImpl object contain references to the old-vc.

    And both properties are read-only properties.

    It looks indeed as if you discovered a flaw in the New-OSCustomizationSpec cmdlet for cloning.

    As a bypass you could create the new OSCustomizationSpec without the cloning option, in other words without using the -OSCustomizationSpec parameter. It will mean unfortunately that you will have to explicitely specify all the other parameters.

    Something like this

    New-OSCustomizationSpec -Name $CUSTSPEC.Name -OSType $CUSTSPEC.OSType -AutoLogonCount $CUSTSPEC.AutoLogonCount ... -Server new-vc


  • 5.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 01:21 PM

    That sounds good. I will try it and then report back.

    Thanks for the hint!



  • 6.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 03:33 PM

    Hi there,

    You hit a bug in New-OSCustomizationSpec cmdlet. I will file a bug.

    There is workaround which you can try. The steps are:

    1. Connect to the old VC server

    2. Copy all specification objects as non persistent objects

    PS> $clientSpec = Get-OSCustomizationSpec | New-OSCustomizationSpec -Type NonPersistent

    3. Disconnect the old VC server

    4. Connect the new VC server

    5. Copy the list of non persistnet objects to the second VC server

    PS> $clientSpec | New-OSCustomizationSpec -Type Persistent

    Regards,

    Vitali

    PowerCLI Team



  • 7.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 06:16 PM

    Hi Vitali,

    this does not work. "$clientSpec = Get-OSCustomizationSpec | New-OSCustomizationSpec -Type NonPersistent" tries to create a Spec on the source server. It fails because the object already exists. I can create a new object with a dummy name, but then i must delete it after the export. I don't want to do any changes on the source system, because normally this is the productive system.

    Thanks for filing the bug!

    regards,

    Birk



  • 8.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 11, 2011 05:42 AM

    Hi Birk,

    I tried those steps on PowerCLI 4.1.1 build 332441. Do you use the same version?

    Vitali



  • 9.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 11, 2011 07:56 AM

    Hi Vitali,

    i use the same version.

    Get-PowerCLIVersion


    PowerCLI Version
    ----------------
       VMware vSphere PowerCLI 4.1 U1 build 332441
    ---------------
    Snapin Versions
    ---------------
       VMWare vSphere PowerCLI 4.1 U1 build 332441
       VMware vCenter Update Manager PowerCLI 4.1 build 266648

    Birk



  • 10.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 12, 2011 06:39 AM

    Hi again Birk,

    I just execute the steps again and it worked fine for me. Assure that the old VC is disconnected.

    Vitali



  • 11.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 16, 2011 05:44 PM

    Hi Vitali,

    i get the following error at step 2.

    New-OSCustomizationSpec        There is already a customization spec with the same name.   

    + $clientSpec = Get-OSCustomizationSpec | New-OSCustomizationSpec <<<<  -Type NonPersistent

        + CategoryInfo          : InvalidArgument: (:) [New-OSCustomizationSpec], InvalidArgument

        + FullyQualifiedErrorId : Client20_VmHostServiceImpl_NewCustomizationSpec_DuplicateCustomizationSpecClient,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewCustomizationSpec 


    1. Connect to the old VC server

    2. Copy all specification objects as non persistent objects

    PS> $clientSpec = Get-OSCustomizationSpec | New-OSCustomizationSpec -Type NonPersistent

    3. Disconnect the old VC server

    4. Connect the new VC server

    5. Copy the list of non persistnet objects to the second VC server

    PS> $clientSpec | New-OSCustomizationSpec -Type Persistent

    New-OSCustomizationSpec tries to create the Specs on the source server instead of filling the $clientspec var...

    Birk



  • 12.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 17, 2011 06:29 AM

    Hi Birk,

    I missed little detail... In the last step, specify explicitly the Server parameter, since this is the destination in this case:

    $clientSpec | New-OSCustomizationSpec -Type Persistent -Server $connectionToNewVC

    This should work.

    Regards,

    Vitali



  • 13.  RE: copy OSCustomizationSpec to another vcenter

    Posted May 10, 2011 06:19 PM

    Hi LucD,

    your hint does not work (out of the box). I must check every parameter for being not $null and then create the New-OSCustomizationSpec command. I have decided two export/import the Specs and wait for a bug fix.

    Thanks again for your hint.

    regards,

    Birk