My snapshot

A screenshot of a computer

Description automatically generated

Code below !

# vCenter Server configuration

$vcenter = “vcenter.vmware.local”

$vcenteruser = “[email protected]

$vcenterpw = “VMware1!”

$vmname = “backup”

#Connect to the vCenter server defined above. Ignore certificate errors

connect-viserver $vcenter -User $vcenteruser -Password $vcenterpw

# change -1 day old to -15 for example delete snapshot older then 15 days and delete from vm name backup – i have 1 day old at moment in code.

Get-VM -Name $vmname | Get-Snapshot |Where {$_.Created -lt (Get-Date).AddDays(1) -and $_.Name -notmatch “donotdelete”} |Remove-Snapshot -Confirm:$false

Create a new snapshot code below!

New-Snapshot -VM “backup” -Name ‘This is a test snapshot’ -Description ‘Testing this out’

By Kader