Microsoft Virtualization Discussions

Command Syntax error

mrcwillis
3,080 Views

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?

 

2 REPLIES 2

mrcwillis
3,073 Views

Figured it out.  I stumbled upon a page about escape characters.  

 

http://msdn.microsoft.com/en-us/library/4edbef7e%28v=vs.110%29.aspx

 

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

 

 

HONIG2012
3,072 Views

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

Public