WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / Which VM was this vSphere VM cloned from?

Which VM was this vSphere VM cloned from?

01.11.2021 by William Lam // 2 Comments

This was a question that I saw back in December on the VMware {code} Slack which was quickly answered by the always awesome Luc Dekens. The solution is to look at vCenter Server Events, which are super rich in information and can be used for a number of things including identifying the source VM that it was cloned from. When I was a customer, this was something I did all the time, using events for auditing purposes but also identifying who, what and when a certain operation was performed including source VMs for cloning operations.

Although this information maybe known to some, there is still not an elegant solution that can help someone quickly identify the source VM for a specific vSphere VM that was cloned. This topic also intrigued me as I have seen this question come up in the past. I figure I might as well add this to my random scripting backlog and take a look when I had some time.

Before taking a look at the solution, it is important to understand the different types of clones that exists in vSphere today and also the respective vCenter Server events that can help us correlate to both the source VM but also the specific clone type.

Cloning Types

  • Full Clone - An independent copy of a virtual machine that shares nothing with the parent virtual machine after the cloning operation. Ongoing operation of a full clone is entirely separate from the parent virtual machine
  • Linked Clone - A copy of a virtual machine that shares virtual disks with the parent virtual machine in an ongoing manner. This conserves disk space, and allows multiple virtual machines to use the same software installation
  • Instant Clone - An independent copy of a virtual machine that starts executing from the exact running state of the source powered on virtual machine. Instant Clone uses rapid in-memory cloning of a running parent virtual machine and copy-on-write, simliar to that of Linked Cloning to rapidly deploy virtual machines

vCenter Event Types

  • VmClonedEvent - Triggered when a Full Clone or Linked Clone has been performed
  • com.vmware.vc.VmInstantClonedEvent - Triggered when an Instant Clone has been performed
  • VmDeployedEvent - Triggered a VM has been deployed either from a vSphere Template or Content Library Template

Using this information, I have created a PowerCLI function called Get-VMCloneInfo which can be installed directly from the PowerShell Gallery by running:

Install-Script VMCloneInfo

The function accepts a single parameter called -VMName which is the name of the VM that you wish to look up the cloning information about. Below are some example output for the various cloning scenarios which will output the clone type, source VM, Date and User that performed the original clone operation.

Cloning Scenarios

#1 - Here is a example when specifying a VM that was not cloned:

> Get-VMCloneInfo -VMName "SourceVM"
Unable to find any cloning information for SourceVM, VM may not have been cloned or vCenter Events have rolled over

#2 - Here is an example when specifying a VM that was Full Cloned:

> Get-VMCloneInfo -VMName "Full-Clone-VM"
Type Source Date User
---- ------ ---- ----
Full SourceVM 1/3/2021 1:13:00 PM VSPHERE.LOCAL\Administrator

#3 - Here is an example when specifying a VM that was Linked Cloned:

> Get-VMCloneInfo -VMName "Linked-Clone-VM"
Type Source Date User
---- ------ ---- ----
Linked SourceVM 1/3/2021 1:13:14 PM VSPHERE.LOCAL\Administrator

#4 - Here is an example when specifying a VM that was Instant Cloned:

> Get-VMCloneInfo -VMName "Instant-Clone-VM"
Type Source Date User
---- ------ ---- ----
Instant SourceVM2 1/3/2021 1:12:44 PM VSPHERE.LOCAL\Administrator

#5 - Here is an example when specifying a VM that was cloned from a vSphere Template:

> Get-VMCloneInfo -VMName "VMTX-VM"
Type Source Date User
---- ------ ---- ----
Full SourceVMTXTemplate 1/3/2021 2:20:31 PM VSPHERE.LOCAL\Administrator

#6 - Here is an example when specifying a VM that was cloned from a Content Library VM Template:

> Get-VMCloneInfo -VMName "VMTemplate-VM"
Type Source Date User
---- ------ ---- ----
Full SourceVMTemplate 1/3/2021 2:23:41 PM VSPHERE.LOCAL\Administrator

More from my site

  • Instant Clone Apple MacOS
  • Instant Clone Microsoft Windows & VM Keystroke VMworld demo and code posted
  • How Wrecking Crew Inc. leveraged vSphere's Instant Clone to instantly provision hundreds of VMs
  • Instant Clone community customization script repository
  • How to VMFork aka Instant Clone Nested ESXi?

Categories // Automation, PowerCLI, vSphere Tags // clone, instant clone, linked clones, PowerCLI

Comments

  1. thekhord says

    02/01/2022 at 3:14 pm

    Can it be adjusted to take a VM MOID or a whole VM object, and provide the source VM's MOID in the output? We run hundreds of sets of the same named VMs so providing a name isn't really feasible for such large scale cases.

    Reply
    • ACME214 says

      02/03/2022 at 9:47 am

      This is a great help provided you already know the name of the vm. We have several guests in the environment that were originally created as clones but we have no idea which ones.
      How can we tweak this to output a list of all guest vms in the vcenter that were created as clones?

      Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Automated ESXi Installation with a USB Network Adapter using Kickstart 02/01/2023
  • How to bootstrap ESXi compute only node and connect to vSAN HCI Mesh? 01/31/2023
  • Quick Tip - Easily move or copy VMs between two Free ESXi hosts? 01/30/2023
  • vSphere with Tanzu using Intel Arc GPU 01/26/2023
  • Quick Tip - Automating allowed and not allowed Datastores for use with vSphere Cluster Services (vCLS) 01/25/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023