Showing posts with label powercli snapshot multiple vms. Show all posts
Showing posts with label powercli snapshot multiple vms. Show all posts

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.

Prerequisites:
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.


Steps:
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.

Thursday 16 February 2017

Taking multiple VMs snapshot – VMware vSphere PowerCLI

Or, How to create multiple VMs snapshot?
Or, How to take snapshot of multiple VMs at once?
Or, Command for taking multiple VMs snapshot.
Or, Taking snapshot of multiple VMs at once.

Descriptions: When you think of snapshot of virtual machines, its easy if you are doing it for one or two machines but its easiest when you thinking to do it for multiple VMs, may be 10-20 or more VMs. Yeah, correct, its was not a typo. J Its even easiest to take snapshot of multiple virtual machines.

The only thing you need is, VMware vSphere PowerCLI.

There are two methods that I use frequently for taking snapshot of multiple virtual machines:

1. Setting up $VMs parameter pointing to the list of virtual machines and then using New-Snapshot cmdlet
2. Typing VMs name manually and then using New-Snapshot cmdlet

Let’s see how?

Steps (Method-1): Setting up $VMs parameter pointing to the list of virtual machines and then using New-Snapshot cmdlet

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

$VMs = Get-VM VM1, VM2, VM3, VM4


Note: replace VM1, VM2, VM3, and VM4 with your Virtual Machines name. You can add more VMs name here after coma (,).



Now, run the below command and hit enter to start the snapshot process:

New-Snapshot -VM $VMs -Name NameOfSnsphot -Description DescriptionOfSnapshot






That’s it, all VMs (VM1, VM2, VM3, and VM4), now would be having a snapshot.

Steps (Method-2): Typing VMs name manually and then using New-Snapshot cmdlet

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

New-Snapshot -VM VM1, VM2, VM3, VM4 -Name NameOfSnsphot -Description DescriptionOfSnapshot

Note: replace VM1, VM2, VM3, and VM4 with your Virtual Machines name. You can add more VMs name here after coma (,).







Cheers, Please write me back if you have any query or feedback..

Saturday 4 February 2017

Virtual Machines name, snapshot name, and snapshot descriptions export to CSV file –VMware vSphere PowerCLI

Or, Virtual Machines snapshot report export to csv file using VMware vSphere PowerCLI.
Or, Finding Virtual Machines with snapshot details using VMware vSphere PowerCLI.
Or, vSphere PowerCLI command to get VMs list with snapshot name and descriptions.

Descriptions: Remember the storage optimization task?, the very first thing we do is we check for the VMs having snapshot. Sometime we end up with having few VMs with very large snapshot data size.

If you have 10-20 VMs, its easy for you to check each VMs individually to see which are the VMs having snapshot but what if you have 100 or 1000 VMs?? Its not possible or even not a wise decision to check each and every VMs individually for this reason.

Therefore, here you have some cool stuffs to do in vSphere PowerCLI. Just few sequential command arrangements and you are done. You can have the list of VMs having snapshot on the CLI dashboard or you can choose to export the list of such VMs in CSV file.…

Steps: Connecting vCenter Server with vSphere Power CLI
Open vSphere PowerCLI > Type the command below and hit enter

Connect-VIServer IPAddressOfvCenterServer












Enter the vCenter Server credentials and say OK (in my case the user name is ‘administrator@vsphere.local)’





















Steps: Getting VMs list with snapshot details on vSphere CLI dashboard
Once you connected successfully with your vCenter server, type the command below and hit enter. Now you will have the VMs List, Snapshot Name Details, and Snapshots Descriptions details as highlighted in below screenshot.

Get-VM | Get-Snapshot | select VM, Name, Description













Steps: Exporting VMs list report with snapshot details in CSV file
To export the VMs list with snapshot details in a CSV file, type the below command and hit enter

Get-VM | Get-Snapshot | select VM, Name, Description | Export-Csv D:\temp\testreport.csv






Note: Please change the Export CSV path to your preferred folder path.

Upon successful completion of the command, you would be having csv report details like below:





Updated 4th Feb 2017
You can try few more commands as given below for detailed report:

To get VM list with VM Name, Snapshot Name, Snapshot Description, Snapshot Creation Date
Get-VM | Get-Snapshot | select VM, Name, Description, Created

To get VM list with VM Name, Snapshot Name, Snapshot Description, Snapshot Creation Date, Snapshot Size in GB
Get-VM | Get-Snapshot | select VM, Name, Description, Created, SizeGB

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