Microsoft Virtualization Discussions

New-NaQtree fails when passing quotes into the cmdlet

tbath2378
4,382 Views

I am trying to create a script that will create numerous qtrees that have spaces in the qtree name.  I am importing the qtree names from a CSV file and building an array with the full path of the qtree.  Here is a overview of how I am building the qtree path:

start-loop:

     $Qtree = [char]34 + "/vol/" + $Volume + "/" + $qtreename + [char]34

end-loop:

Execute the qtree creations:

start-loop:

     New-NaQtree $Qtree

end-loop:

If I write the command to the screen with the following command I can copy and paste the output and it runs just fine:

write-host "New-NaQtree" $Qtree 

    

When I attempt to loop through the array and execute the qtree creations it fails because it "can't determine volume/qtree names"  The quotes in the path seem to be messing with the ability to find the qtree path.  I attempted to put the entire command into the array and use the invoke expression to run the command.  Here is a sample of what I tried:

start-loop:

     $Qtree = "New-NaQtree " + [char]34 + "/vol/" + $Volume + "/" + $qtreename + [char]34

end-loop:

Execute the qtree creations:

start-loop:

     ($Qtree) | Invoke-Expression

end-loop:

This seems to work but it drops the quotes so all of the qtree names that contain spaces are created incorrectly.  Can someone please help me figure out how to get these qtrees created when using quotes??

1 ACCEPTED SOLUTION

timothyn
4,382 Views

Looks like a problem with the way the toolkit handles QTree paths with spaces.  Until that's resolved, you can invoke the API directly like this:

Invoke-NaSystemApi "<qtree-create> <volume>$Volume</volume> <qtree>$qtreename</qtree> </qtree-create>"

Not real pretty, but it should do what you want...

View solution in original post

4 REPLIES 4

bsti
4,382 Views

My guess is this is not possible through the API ( and thus the new-naqtree cmdlet).  I don't see a way to get this to work.

However, there is a workaround.  Try:

$qtree = "/vol/$volumename`/$qtreename"

Invoke-NaSsh "qtree create `"$qtree`""  

One other note, is the storage management guide recommends against using certain characters (namely, spaces and commas) in QTree names for various reasons, including that it breaks SnapMirror:

Qtree name restrictions

Using some special characters in qtree names, such as commas and spaces, can cause problems with

other Data ONTAP capabilities, and should be avoided.

The following characters should be avoided in qtree names:

• Space

Spaces in qtree names can prevent SnapMirror updates from working correctly.

• Comma

Commas in qtree names can prevent quotas from working correctly for that qtree, unless the name

is enclosed in double quotation marks.

tbath2378
4,382 Views

Thank you for the reply.  The issue is that we are moving from a legacy Celerra to the Netapp and all of the tree quotas on the Celerra were created with the spaces in the names.  In order to not break everything we had to leave the spaces in place.

timothyn
4,383 Views

Looks like a problem with the way the toolkit handles QTree paths with spaces.  Until that's resolved, you can invoke the API directly like this:

Invoke-NaSystemApi "<qtree-create> <volume>$Volume</volume> <qtree>$qtreename</qtree> </qtree-create>"

Not real pretty, but it should do what you want...

tbath2378
4,382 Views

Eric,

Thanks so much that works like a champ!!  Now I am also having an issue with setting quotas on the qtree when there are space is the name.

I believe I can use the same invoke-NaSystemApi "<quota-add-entry> "??  But I am unsure on the rest of the syntax.  My command would have been Add-naquota tree "/vol/office01/A B" -Threshold 100g.  This of course is having the same issue as the earlier qtree create command.

Thanks,

Tom

Public