<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://vwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Linked_Clone_Script_Extracts_and_Examples</id>
	<title>Linked Clone Script Extracts and Examples - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://vwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Linked_Clone_Script_Extracts_and_Examples"/>
	<link rel="alternate" type="text/html" href="http://vwiki.co.uk/index.php?title=Linked_Clone_Script_Extracts_and_Examples&amp;action=history"/>
	<updated>2026-05-20T08:31:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://vwiki.co.uk/index.php?title=Linked_Clone_Script_Extracts_and_Examples&amp;diff=1975&amp;oldid=prev</id>
		<title>Sstrutt: Initial creation</title>
		<link rel="alternate" type="text/html" href="http://vwiki.co.uk/index.php?title=Linked_Clone_Script_Extracts_and_Examples&amp;diff=1975&amp;oldid=prev"/>
		<updated>2012-06-06T14:19:18Z</updated>

		<summary type="html">&lt;p&gt;Initial creation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Create Linked Clone ==&lt;br /&gt;
The following will allow you to create a Linked Clone of an existing VM.  Similar to normal cloning the source VM doesn&amp;#039;t need to be powered off, but if possible is probably a good idea.&lt;br /&gt;
&lt;br /&gt;
Be aware that Linked Clones cannot be Storage vMotioned (they can be cold migrated)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
$SrcVmName = &amp;quot;Master-VM&amp;quot;               # Name of VM to clone (will be base/parent of linked clone&lt;br /&gt;
&lt;br /&gt;
$NewVmName = &amp;quot;Child-VM&amp;quot;                # New of new linked clone&lt;br /&gt;
$CreateInFolder = &amp;quot;Spawn&amp;quot;              # Optional - folder for new linked clone&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$Vm = Get-VM $SrcVmName&lt;br /&gt;
&lt;br /&gt;
# Create temporary snapshot to create clone from&lt;br /&gt;
$SrcVmSnap = New-Snapshot -VM $Vm -Name &amp;quot;Clone Snapshot&amp;quot; -Quiesce:$true -Confirm:$false&lt;br /&gt;
&lt;br /&gt;
# Get view of source VM&lt;br /&gt;
$SrcVMview = Get-View (Get-VM $SrcVmName)&lt;br /&gt;
&lt;br /&gt;
# Create RelocationSpecification - defines destination of clone&lt;br /&gt;
$relocateSpec = New-Object Vmware.Vim.VirtualMachineRelocateSpec&lt;br /&gt;
$relocateSpec.DiskMoveType = [Vmware.Vim.VirtualMachineRelocateDiskMoveOptions]::createNewChildDiskBacking&lt;br /&gt;
  &lt;br /&gt;
# Create CloneSpecification - defines overall cloning operation&lt;br /&gt;
$cloneSpec = New-Object Vmware.Vim.VirtualMachineCloneSpec&lt;br /&gt;
$cloneSpec.Location = $relocateSpec&lt;br /&gt;
$cloneSpec.Snapshot = $SrcVmSnap.Id&lt;br /&gt;
&lt;br /&gt;
if ($CreateInFolder) {&lt;br /&gt;
    $Folder = (Get-Folder $CreateInFolder).Id&lt;br /&gt;
} else {&lt;br /&gt;
    $Folder = $Vm.Parent&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$SrcVMview.CloneVM($Folder, $NewVmName, $cloneSpec)&lt;br /&gt;
&lt;br /&gt;
Remove-Snapshot $SrcVmSnap -Confirm:$false&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whilst you can specify that the new VM is created on a different datastore to the parent VM, only the VMDK(s) are located there, all other VM files are located on the source datastore.  Therefore its normally preferable to move following the new following its creation using [http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Move-VM.html Move-VM], but this isn&amp;#039;t required add the the destination datastore to the Relocation Specification...&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
$relocateSpec.Datastore = (Get-Datastore &amp;quot;DatastoreName&amp;quot;).Id&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:PowerCLI]]&lt;br /&gt;
[[Category:Virtual Machine]]&lt;/div&gt;</summary>
		<author><name>Sstrutt</name></author>
	</entry>
</feed>