Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 252940

delete clones older than x days

$
0
0

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


Viewing all articles
Browse latest Browse all 252940

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>