PowerCLI – Listing snapshots

In this series, we will retrieve the list of all the Virtual Machine (VMs) with snapshots inside our vCenter Cluster.
You can refer to our previous post on how to install powercli on Rocky or Linux mint.

Launching Powercli

# Starting powercli

Login into vCenter

In order to interact with the vCenter or ESXi, you will first need to authenticate with with system before being able to run any commands.
Since our vCenter is using a self signed certificate, we will first need to tell powershell to ignore the validation of the certificate.

PS /home/jean> Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore

We can now connect and authenticate against vCenter by using the “Connect-VIServer” and specifying the IP Address of our target server.

PS /home/jean> Connect-VIServer ""

Specify Credential
Please specify server credential
User: administrator@vsphere.local
Password for user administrator@vsphere.local: **********

Name                           Port  User
----                           ----  ----                   443   VSPHERE.LOCAL\Administrator

Listing all host in vCenter

To validate that our connection is successful, we can try to list all the hosts available within our environment by using the “get-vmhost” command.

PS /home/jean> get-vmhost

Name                 ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz   MemoryUsageGB   MemoryTotalGB Version
----                 --------------- ---------- ------ ----------- -----------   -------------   ------------- -------        Connected       PoweredOn      28       14273       55972         305.722         510.663   6.7.0        Connected       PoweredOn      28       25421       55972         186.861         447.413   6.7.0        Connected       PoweredOn      28       15567       55972         215.700         510.663   6.7.0

Snapshots listing

The objective of this post is to create a list of virtual machines currently having snapshots in our environment.
To achieve this, we will employ a series of commands, focusing exclusively on extracting the specific field of interest. We only want the name of the VM, the name of the snapshot and the date the snapshot was created. We also want the output to nicely display in a table format.

PS /home/jean> Get-VM | Get-Snapshot | select VM, Name, Created | Format-Table VM, Name, Created -AutoSize

VM                      Name                                    Created
--                      ----                                    -------
Debian-11               OS Install                              4/12/2023 11:22:01 AM
Win10-testing           Clean Image                             7/11/2022 10:52:41 AM
FlareVM-win10           Flare Installed and configured          3/15/2023 11:21:45 PM
Unifi-controller        Prior upgrade to version 7.2.92         8/10/2022 6:39:01 PM

Get-VM : retrieves the virtual machines on a vCenter Server system.
Get-Snapshot : returns information about the snapshots that correspond to the list of virtual machines provide by the output of “Get-VM“.
Select VM, Name, Created : This statement allows us to retrieve only the field that we are interested to from the result of the previous command “Get-Snapshot
Format-Table VM, Name, Created -AutoSize: this statement format the output into a table to make it easier to read.


Below you will find a screenshot showing all the steps taken to connect, authenticate, list hosts and list all the VMs with snapshots.

Summary showing how to connect to vCenter, list hosts, list snapshots.

Useful PowerCLI references

If you have any questions or require assistance, we are actively seeking strategic partnerships and would welcome the opportunity to collaborate. Don’t hesitate to contact us!


Stay in the loop! Sign up for our newsletter today for getting regular updates.