Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
hi guys,
I am trying to delete all snapshots older than 2 days and that don't have @snapmir@ in them
I was trying this but 'whatif' tells me that the snapmirror snapshots will still be deleted
Get-NaVol | Get-NaSnapshot | where-object {($_.Created -lt (Get-Date).AddDays(-2)) -and ($_.name -ne "@snapmir@*")} | remove-nasnapshot -whatif
here's an example of a snapmirror snapshot I want to keep:
@snapmir@{8DEC61ED-452A-4B21-8EDE-18503B0A2E37}
what am I doing wrong?
thank you
Joel
Solved! See The Solution
Hi Joel,
I think you might want to use -notlike instead of -ne so the wildcard is evaluated.
I just did a quick test:
PS C:\> '@snapmir@{8DEC61ED-452A-4B21-8EDE-18503B0A2E37}' -ne "@snapmir@*"
True
PS C:\> '@snapmir@{8DEC61ED-452A-4B21-8EDE-18503B0A2E37}' -notlike "@snapmir@*"
False
I hope that helps!
-Steven
Hi Joel,
I think you might want to use -notlike instead of -ne so the wildcard is evaluated.
I just did a quick test:
PS C:\> '@snapmir@{8DEC61ED-452A-4B21-8EDE-18503B0A2E37}' -ne "@snapmir@*"
True
PS C:\> '@snapmir@{8DEC61ED-452A-4B21-8EDE-18503B0A2E37}' -notlike "@snapmir@*"
False
I hope that helps!
-Steven
YES!!! like a charm
Steven,
'whatif' showed no issue but when I actually try to delete I am getting this:
VERBOSE: Deleting snapshot exchsnap__ex_08-30-2013_19.05.47__daily from volume exch2_1.
Remove-NaSnapshot : Could not find file 'C:\Users\admin\AppData\Local\Temp\omxngtox.dll'.
At line:1 char:244
+ Get-NaVol | Get-NaSnapshot | where-object {($_.Created -lt (Get-Date).AddDays(-5)) -and ($_.name -notlike "@snapmir@
*") -and ($_.name -notlike "hourly*") -and ($_.name -notlike "nightly*") -and ($_.name -notlike "smvi_*")} | remove-nas
napshot <<<< -confirm:$false -verbose
+ CategoryInfo : InvalidOperation: (10.5.5.5:NaController) [Remove-NaSnapshot], FileNotFoundException
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.Snapshot.RemoveNaSnapshot
here is the script:
PS C:\Windows\system32> Get-NaVol | Get-NaSnapshot | where-object {($_.Created -lt (Get-Date).AddDays(-2)) -and ($_.nam
e -notlike "@snapmir@*") -and ($_.name -notlike "hourly*") -and ($_.name -notlike "nightly*") -and ($_.name -notlike "sm
vi_*")} | remove-nasnapshot -confirm:$false -verbose
any ideas?
cheers
Does anything from Thread Link : 12737 help? It's possible a restart of the PowerShell session or host might resolve it.
-Steven
yep, restarted the session and it went fine
Steven, is there something you don't know?