MariusRoma
Expert
Expert

Cloning a VM from a snapshot

I have a running VM with some snapshots.

One of the snapshot was created some says ago when the VM was powered off.

I need to create a new VM (full clone) from that snapshot.

I was told that the only way is using PowerCli.

Where can I locate a sample script to start from?

Regards

marius

0 Kudos
3 Replies
LucD
Leadership
Leadership

Jonathan has a sample script for that, see Clone a VM from a Snapshot using PowerCLI

Also read the comments for some fixes.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
mkfm
Enthusiast
Enthusiast

just incase someone lands here, coming from google, looking for a simple solution: I found a way using just default cmdlets:

First create a linked clone from the snapshot, then a full clone of the linked clone, then remove the linked clone
(https://kb.vmware.com/s/article/1026753 gave me the idea)

$snap = Get-Snapshot -VM myVM -Name mySnapshot
New-VM -Name "$($snap.VM.Name)-linkedClone" -VMHost $snap.VM.VMHost -VM $snap.VM -ReferenceSnapshot $snap -LinkedClone
New-VM -Name "$($snap.VM.Name)-Clone" -VMHost $snap.VM.VMHost -VM "$($snap.VM.Name)-linkedClone"
Remove-VM -VM "$($snap.VM.Name)-linkedClone" -DeletePermanently -Confirm:$false

broken_shipyard
Contributor
Contributor

@mkfm..

My humbly thanks to your post above, it really saved my day

All the best

/Gus

 

0 Kudos