1. Run sysprep and reseal the VM for cloning. Shut it down when finished and do not turn it on.
2. Install PowerCLI
3. Get the script: http://poshcode.org/1549 :
param ( [parameter(Mandatory=$true)][string]$SourceName, [parameter(Mandatory=$true)][string]$CloneName ) $vm = Get-VM $SourceName
# Create new snapshot for clone $cloneSnap = $vm | New-Snapshot -Name "Clone Snapshot"
# Get managed object view $vmView = $vm | Get-View
# Get folder managed object reference $cloneFolder = $vmView.parent
# Build clone specification $cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec $cloneSpec.Snapshot = $vmView.Snapshot.CurrentSnapshot
# Make linked disk specification $cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec $cloneSpec.Location.DiskMoveType = [Vmware.Vim.VirtualMachineRelocateDiskMoveOptions]::createNewChildDiskBacking
# Create clone $vmView.CloneVM( $cloneFolder, $cloneName, $cloneSpec )
# Write newly created VM to stdout as confirmation Get-VM $cloneName
I have got it saved as Create-LinkedClone.ps1
4. start PowerCLI, connect to your vCenter server and run the script:
You can also run this:
And here is a screen dump of my vCenter server with the Clone:
Now let’s start up the Clone:
Sysprep will take us through the setup.