One thought on “Linked clones in VMware with Powershell

  1. An example of this script spinning out several VMs from the same base system

    connect-viserver VCserverName
    $vm = get-vm base_Win7
    $cloneSnap = $vm | New-Snapshot -Name "Clone Snapshot"
    $vmView = $vm | Get-View
    $cloneFolder = $vmView.parent
    $cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec
    $cloneSpec.Snapshot = $vmView.Snapshot.CurrentSnapshot
    $cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec
    $cloneSpec.Location.DiskMoveType = [Vmware.Vim.VirtualMachineRelocateDiskMoveOptions]::createNewChildDiskBacking
    $vmView.CloneVM( $cloneFolder, "Win7_001", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_002", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_003", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_004", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_005", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_006", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_007", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_008", $cloneSpec)
    $vmView.CloneVM( $cloneFolder, "Win7_009", $cloneSpec)

Leave a Reply

Your email address will not be published. Required fields are marked *