Snapshot report (old only)

This post was originally published on this site

I have a report that currently shows all snapshots running at that point in time, but I am really only needing to see snaphots that are older than X days, how can I add that limitation.

 

#############################

#         Variables         #

#############################

$date=Get-Date -format “yyyy-MMM-d”

$datetime=Get-Date

$filelocation=”varwwwSnapshotssnapshot-$date.htm”

 

#############################

#          Content          #

#############################

$report = Get-VM | Get-Snapshot | Where {$_.vm -NotLike “*_replica*”} | Select-Object vm,name,sizeGB,created,powerstate

 

#############################

# Add Text to the HTML file #

#############################

$report | ConvertTo-Html –title “VMware Snapshot Check ” –body “<H1>VMware Snapshot Check</H1>” -head “<link rel=’stylesheet’ href=’style.css’ type=’text/css’ />” | Out-File $filelocation

ConvertTo-Html –title “VMware Snapshot Check ” –body “<H4>Date and time</H4>”,$datetime -head “<link rel=’stylesheet’ href=’style.css’ type=’text/css’ />” | Out-File -Append $filelocation

ConvertTo-Html –title “VMware Snapshot Check ” –body “<H4>VM Count</H4>”,$report.Count -head “<link rel=’stylesheet’ href=’style.css’ type=’text/css’ />” | Out-File -Append $filelocation

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.