PowerCLI

 View Only
  • 1.  Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 02:07 AM

    My code creates a regular-clone when it should create a linked-clone, please help.

     

    # Confirm we can new-VM to a storageCluster
    # BUT IT IS NOT LINKED.  IT IS LARGE AND TAKES TIME TO COPY
    
    $BaseVM = "daa-snap-all-U2204-DESK"
    $ResultingVMName = "chris-test-snapclone-to-datastore-cluster"
    $ResourcePool = get-resourcepool rp-ti-ucs 
    $FirstSnapShot = (get-vm $BaseVM | Get-Snapshot)[0]
    
    Measure-Command {
        $LinkedClone = New-VM `
            -Name $ResultingVMName `
            -VM $BaseVM `
            -Datastore (Get-DatastoreCluster)[0] `
            -ResourcePool $ResourcePool `
            -LinkedClone `
            -ReferenceSnapshot $FirstSnapShot
    }
    
    Get-VM $BaseVM          | Select-Object Name, ProvisionedSpaceGB, @{n = "HardDiskSizeGB"; e = { (Get-HardDisk -VM $_       | Measure-Object -Sum CapacityGB).Sum } } | ft -a 
    $FirstSnapShot          | Select-Object Name, SizeGB,             @{n = "HardDiskSizeGB"; e = { (Get-HardDisk -Snapshot $_ | Measure-Object -Sum CapacityGB).Sum } } | ft -a 
    Get-VM $ResultingVMName | Select-Object Name, ProvisionedSpaceGB, @{n = "HardDiskSizeGB"; e = { (Get-HardDisk -VM $_       | Measure-Object -Sum CapacityGB).Sum } } | ft -a 

     

     

    Output is:

    chrischrischris_0-1706580303654.png

     

     



  • 2.  RE: Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 11:27 AM

    Is the reference snapshot located on the same DatastoreCluster?



  • 3.  RE: Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 05:54 PM

    Yes.  The reference snapshot is located on the same DatastoreCluster.



  • 4.  RE: Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 06:07 PM

    Strange, it should work when on the same DatastoreCluster.

    For testing, can you try to create the linkedclone on the same Datastore as where the reference snapshot is located?



  • 5.  RE: Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 08:22 PM

    I was able to successfully create a linkedclone on the same Datastore as where the reference VM is located.

    Changed the -Datastore to be the datastore of the reference VM:

     

            -Datastore (get-vm $BaseVM    | Get-datastore)[0] `

     

     

    Output is:

    chrischrischris_0-1706645858749.png

    Although the output shows "chris-test-snapclone-to-datastore-cluster" with a HardDiskSizeGB of 50.000, the actual size is smaller:

    chrischrischris_1-1706646111570.png

    Although the actual size is small, the vCenter GUI shows the new VM as consuming over 15.82GB of storage:

    chrischrischris_0-1706646731933.png

     



  • 6.  RE: Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 08:25 PM

    If that doesn't work with any other datastore in that datastorecluster then there seems to be an "issue".

    According to the doc a DatastoreCluster should work as well.

    Perhaps open an SR?



  • 7.  RE: Code creates a regular-clone when it should create a linked-clone....

    Posted Jan 30, 2024 11:27 PM

    Will do!

    Thanks