Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
The powershell script I use to update my snapvault has stopped working. A brief investigation shows that the snapshot name selection process has failed.
I use the commandlet
$smeEXsnap = Get-NaSnapshot exdb1 exchsnap__* | select-object Name -last 1
it retuns "exchsnap__exmbx1_12-31-2011_23.40.13__daily"
Snaps on filer
SAN> snap list -n exdb1
Volume exdb1
working...
date name
------------ --------
Jan 02 23:43 exchsnap__exmbx1_01-02-2012_23.40.13__daily
Jan 02 00:01 exchsnap__exmbx1_01-01-2012_23.40.14__daily
Jan 01 00:11 exchsnap__exmbx1_12-31-2011_23.40.13__daily (snapvault)
Dec 30 23:42 exchsnap__exmbx1_12-30-2011_23.40.13__daily
The work around is simple in that I can manually run my script with the snapshot name to update the snapvaults and then remove the snapshots from last year. But I would like to know if this is a 'bug' in the commandlet or I need to change my code so that 'last' also takes in the year value.
Thanks
Bren
PS - Happy new year all
I am also getting this trouble since I can not include in the year value into result list? Is there any solution to solve that?
Thanks
You have to sort the results by date and then select last 1.
Get-NaSnapshot volname | Sort-Object Created | Select-Object -last 1
regards,
Mladen
This bug bit me too, because I have scripts that automatically mount snapshots and do some processing for a SQL process I've created. Once the December backups were gone, it started working again. Fortunately, I'd fixed the problem by then.
"Sort-Object Created" will not work. "Created" is not the actual field name for the date the snapshot was created, even though it's column display name is "Created".
I work around the sorting problem by doing this...
get-nasnapshot -Name volname | Where { $_.Name -like "sqlsnap*" } | Sort-Object AccessTime,Name -descending | Select -Last 1
This will get me any snapshot named "sqlsnap*", so I'm filtering out the automatic snapshots for my snapmirror process, etc.. Then I sort the object from most recent to least recent by the date the snapshot was created and the name of the snapshot. The name is just in there as a safety measure, I guess. There's little chance that two snapshots could have the same exact creation time.