Forum Discussion

Jhult1170's avatar
Jhult1170
Copper Contributor
Feb 25, 2026

stop expanding parentheses in a variable

Hello 

 

We have created a script using PowerShell and Box CLI to create groups in Box as a user request them. We have had success with the script until recently.

We had a user request that failed

$ClientName="Test-Group(Name)"
$BoxClientOwnerName="$($ClientName)_Owner"
$BoxLOWGRPRaw="$( Box groups:create --json $BoxClientOwnerName )"

The script returns the error 
_Owner was unexpected at this time.

If we enter the group name not as a variable, it will work

$BoxLOWGRPRaw="$( Box groups:create --json "Test-Group(Name)" )"

 

We believe that it is trying to expand the information in the ()

We have tried several different ways to create the group variable name, but have not had success yet.

We have tried to use escape characters to stop the processing of the (), but no success.

 

Could you please help us resolve this issue?

 

Thank you

1 Reply

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    Hi Jhult1170​ ,

     

    I do not have a command called "box", so I can't test your exact use case, however, it's worth noting that your manual example line of:

     

    $BoxLOWGRPRaw="$( Box groups:create --json "Test-Group(Name)" )"

     

    Is not what your first three lines would be producing. Rather, based on your initial three lines, the proper manual test case would look like:

     

    $BoxLOWGRPRaw = "$( Box groups:create --json Test-Group(Name)_Owner )"

     

    This is because you have used the $BoxClientOwnerName variable in your third line rather than the $ClientName variable.

     

    Cheers,

    Lain