2015-01-14 09:17 AM
1st, I'm a horrible scripter and admittedly know nothing but trying to use powershell more and more. However after a Cmode transistion I'm trying to clean up old snapshots. However some of the old snapshots for snapmirrors have (XX) in the name which is throwing an error in Powershell that as a newby I dont know how to fix after an hour of googling.
Help the noob? I know it has to do with the () however "" or '' doesnt tell it that it is a name.
Remove-NcSnapshot BLTEntVaultSrv01_Index GMDNASDRC7-VF0(2017635997)_BLTEntVaultSrv01_Index.2214 -VserverContext BLTNASPRD-SVM2 -confirm:$False
And I get back: Remove-NcSnapshot BLTEntVaultSrv01_Index GMDNASDRC7-VF0(2017635997)_BLTEntVaultSrv01_Index.2214 -VserverContext BLTNASPRD-SVM2 -confirm:$False
and I get back:
Remove-NcSnapshot : A positional parameter cannot be found that accepts argument '2017635997'.
At line:1 char:1
+ Remove-NcSnapshot BLTEntVaultSrv01_Index GMDNASDRC7-VF0(2017635997)_BLTEntVaultS ...
+ CategoryInfo : InvalidArgument: ( [Remove-NcSnapshot], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapshot.RemoveNcSnapshot
Help pretty please?
2015-01-14 10:30 AM
Figured it out. I stumbled upon a page about escape characters.
Essentially I had to put a series of ' around the charcters telling it that it wasnt a command or argument.
Remove-NcSnapshot BLTEntVaultSrv01_Index GMDNASDRC7-VF0'('2017635997')'_BLTEntVaultSrv01_Index.2214 -VserverContext BLTNASPRD-SVM2 -confirm:$False
2015-01-14 10:33 AM
well i would have also tried it with "" or '' - but if it's not working i would try to workarround
perhaps something like this works:
Remove-NcSnapshot BLTEntVaultSrv01_Index "GMDNASDRC7-VF0*_BLTEntVaultSrv01_Index.2214" -VserverContext BLTNASPRD-SVM2 -confirm:$False
but only as long as you don't have another snapshot which has the same name but diferrent stuff within the brackets - perhaps check that first - otherwhise their also gone -whatif is your friend
let me know if it worked