Hi Guys,
I am trying to create a ps script that will be used to clone a VM and as part of the script only keep two instances of the clones.
This is the code i have at the moment but i am struggling to determine how create the condition to check for how old a VM is and delete a VM that is older than 2 days after a successful clone has completed.
#Date and Time
$now = Get-Date -format d
# Number of Days retention
$createddate = $now.AddDays(-2)
#VM Clone
New-VM -name "test-$now" -vm test -vmhost esx1.test.com -datastore datastore1
#
Any help would be great
Thanks
Dougie