Friday, 17 February 2017

Multiple Virtual Machines snapshot using CSV file input and vSphere PowerCLI

Or, How to take snapshot of multiple VMs from CSV file VMs list?
Or, Import-CSV VMs snapshot using vSphere PowerCLI
Or, Taking snapshot of multiple VMs listed in CSV file

Descriptions: In my previous article, I explained how you could perform snapshot of multiple Virtual Machines using vSphere PowerCLI, but in that article, we just did the listing on VMs on the CLI console itself.

Now, in this article the approach of listing Virtual Machines is changed. We will use a CSV or excel file to import the list of VMs and then will perform snapshot on those VMs with vSphere PowerCLI.

1. List of VMs written in CSV file in the given/supported format
2. VMware vSphere PowerCLI

Preparing the CSV file:

In the CSV file, write the name of Virtual Machines in sequence under “Name” column as shown below:

Note: My CSV file contains two Virtual Machines (VM-1 and VM-2). You can add more VMs name as per your requirement.

Open vSphere PowerCLI > Connect to your vCenter server > Type the command given below and hit enter:

Import-Csv D:\VMsList.csv | %{Get-VM $_.Name} | New-Snapshot -Name TestSnapshot -Description TestDescriptions

IMP Note: Change the following as per your convenience

Path: D:\VMsList.CSV (Change it to your CSV file path)
Name: TestSnapshot (Change the name of the snapshot as per your requirement)
Description: TestDescriptions (Change the description as per your requirement)

Once the command is completed, it should look like below:

Do not worry about the yellow warning appearing below the command. Snapshots of the virtual machines covered in the CSV file already initiated.

Cheers, please write me back if you have any query or feedback on this.


  1. Very Helpfull Kb for me.. Thanks Amit.

  2. Great work, its working !!!!!

  3. launchin this command :
    Import-Csv D:\VMsList.csv | %{Get-VM $_.Name} | New-Snapshot -Name TestSnapshot -Description TestDescriptions

    i receive that %{Get-VM $_.Name} , NAME is invalid argument !!

    can someone help me ?

  4. Hello, Thanks for writing in.. Looks like you have not set the CSV file naming format correctly...Name column is picked from the CSV file's first column as shown in the screenshot..

    Please verify that once and if still there is any issue, please write me back if screenshot if possible..

    Thanks, Cheers

  5. Very useful script, for all VMware Admins.Thanks Bro for sharing good stuff