Hi,
I have a problem on this small report. Somewhere must be something wrong, because the output is not true if id do some tests!
The Report should only contains VMs´where snaphot is older than 24 hours or vm´s with snapshots older than 5 days(with exception tag).
The exclusion to hold snaphots until 5 days is a certian tag.
Based on this report the snapshots will be removed.
For quick testing the time value is changed to minutes!
$excludeVM = Get-Content 'C:\00\SnapshotReport\exclude.txt'
$includeVM = Get-Cluster test* | Get-VM | where{$excludeVM -notcontains $_.Name} | Sort-Object -Property Name
$includeVM
#
$tag = Get-Tag -Name 'snapshot5days' -Category 'snapshot'
clear-variable Snapreport
$Snapreport = $includeVM | Get-Snapshot | Where {(($_.Created -lt (Get-Date).addminutes(-1)) -and
($_.vm.Name | where{ (Get-TagAssignment -Entity $_).Tag.Id -notcontains $tag.Id})) -or ($_.Created -lt (Get-Date).addminutes(-5))}
$Snapreport