Thursday, April 01, 2010

Linked clones in VMware with Powershell

Linked clones in VMware via powershell
http://poshcode.org/1549



1 comment:

edgoad said...

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)