Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180923

schedule Remove-snapshot

$
0
0

Hi, I'm New User for PowerCLI,I have a question for schedule Remove-snapshot:

 

for example:

I have been created a snapshot in PowerCLI for my vm:

$Date = Get-Date -UFormat %Y%m%d

$timechop = Get-Date -Format g

get-vm | where {$_.PowerState -eq "PoweredOn"} | where {$_.Name -match "Linux"} | New-Snapshot -Name "$Date" -Description "PowerCLI Weekly Snapshot at $timechop"

 

get-vm | where {$_.PowerState -eq "PoweredOn"} | where {$_.Name -match "Linux"} | Get-Snapshot

Name                 Description                    PowerState

----                 -----------                    ----------

20190104             PowerCLI Weekly Snapshot at... PoweredOn

 

Now the question:

I need to Schedule Remove the Snapshot Before 7 days ago (according the snapshot create day,for example:20190104,autoremove the named"20190104" when the current date is change to 20190111),how to write the scripts?

 

thanks a lot!


Viewing all articles
Browse latest Browse all 180923

Trending Articles



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