Microsoft Virtualization Discussions

Command Syntax error


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.


I'm running:

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?




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




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

best AJ

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner