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
I have started this blog to share my work experience and spread some smart solutions on Linux to Internet community. I'm hoping more people will get benefited from this blog. Brief about me: I have 14+ years experience working as System Admin and currently work with VMware.