Tuesday, April 29, 2014

Creating vSphere VM Snapshot for a given list of servers



#Taking the input from user
$File_Name = Read-Host "Provide the filename that contains the list of Servers "
$VM_list = Get-Content "$File_Name"

Write-Host "VMName`t`t`t      SnapShot Name`t`t`t`t`t    Size of Snapshot"
# Checking each Server one by one
foreach($CHK_VM in $VM_List) {
$Cap_VM_Info = Get-VM $CHK_VM | Get-Snapshot | Select VM, Name, SizeGB
$Name = $Cap_VM_Info.VM
              $SnapshotName = $Cap_VM_Info.Name
              $SizeOfSnapshot = $Cap_VM_Info.SizeGB

Write-Host "$Name`t`t$SnapshotName`t`t`t$SizeOfSnapshot"
}



Get-VM | Sort Name | Get-Snapshot | Where { $_.Name.Length -gt 0 } | Select VM,Name,Created,SizeMB

No comments:

Post a Comment

Popular Posts

About Me

My photo
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).