Powercli batch create and delete VM snapshots
Note: 1. The client needs to install vmware powercli client 2. users connected to vcenter or esxi hosts must have the permission to connect to and create and delete snapshots 1. Create a VM snapshot # Add a vmware module commandAdd-PSSnapin-Name * vmware * # Fill in connection information, enter the vcenter/esxi Server ip address username and password as required $ vcenterip = Read-Host "Enter the vcenter/esxi Server ip address ...... "$ domainname = Read-Host" Please enter domain name. No value can be left blank ...... "$ username = Read-Host" Enter the user name ...... "$ userpassword = Read-Host" enter the password ....... "-AsSecureStringConnect-VIServer-Server $ vcenterip-User $ username-Password $ userpassword # Takes a snapshot of all virtual machines on the windows system. The snapshot name is test; get-vm | where {$ _. guest-like "* Windows *"} | where {$ _. powerState-eq "PoweredOn"} | New-Snapshot-Name "test" # output the Snapshot information of the vm get-vm | Get-Snapshot | Select-Object vm, name 2. delete a VM snapshot # Add a vmware module commandAdd-PSSnapin-Name * vmware * # enter the connection information, enter the vcenter/esxi Server ip address username and password as required $ vcenterip = Read-Host "Enter the vcenter/esxi Server ip address ...... "$ domainname = Read-Host" Please enter domain name. No value can be left blank ...... "$ username = Read-Host" Enter the user name ...... "$ userpassword = Read-Host" enter the password ....... "-AsSecureStringConnect-VIServer-Server $ vcenterip-User $ username-Password $ userpassword # delete a vm snapshot by snapshot name get-vm | get-snapshot-name" 20150908 "| remove-snapshot