Microsoft Virtualization Discussions

Need help scripting

CASTROJSEC
3,131 Views

I need some help coming up with the script to check these snapdive snapshots for ones older than 30 days and deleteing them.  I can't change naming conventions.  The naming convention is adding get-date -format yyyyMMddHHmmss to "windows-". Any thoughts?

1 ACCEPTED SOLUTION

CASTROJSEC
3,131 Views

Thanks Nick.  I did figure it out.  I'll post it soon.  I'm going to try what you have provided.  Looks good.

View solution in original post

2 REPLIES 2

NHANAS_RS
3,131 Views

Not sure if you figured this out already but for anyone else... the lines below will get the current date, list volumes, filter out offline volumes and ignore read-only volumes, get each of their snapshots older than 30days where there is no dependency(clone, etc) on the volume and then finally remove the snapshots. Hope that helps.

$Now = get-date

get-navol | where-object {$_.State -eq "online" -and $_.raidstatus -notlike "*read-only"} | get-nasnapshot | where-object {$_.AccessTimeDT -le $Now.AddDays(-30) -and $_.Dependency -eq ""} | remove-nasnapshot

CASTROJSEC
3,132 Views

Thanks Nick.  I did figure it out.  I'll post it soon.  I'm going to try what you have provided.  Looks good.

Public