locked
How do Iplace a brace in a string array? RRS feed

  • Question

  • Parameter(  
                Mandatory = $False,
                # Strings to look for that cause an indentation.
                ParameterSetName = '',  
                ValueFromPipeline = $False)] # End [Parameter(  
                $IndentationStrings = @('{','[','(','"','''), # Default Powershell
            [Parameter(  
                Mandatory = $False,
                # Strings to look for that relieve an outdentation. Must have a one-to-one match with indentation strings
                ParameterSetName = '',  
                ValueFromPipeline = $False)] # End [Parameter(  
                $OutdentationStrings = @('}',']',')','"','''), # Default Powershell
     I am getting a syntax error (unexpected token }) on the second parameter statment (the fourth in the sctipt). I have tried everthing I can think of( backticks, doube quotes, additional parens, etc), any help would be greatly appreciated.
    Friday, April 15, 2016 7:50 PM

Answers

  • $IndentationStrings = @('{','[','(','"',''')
    IMHO instead of ''' you have to use '''' or "'"


    my blog: http://shserg.ru/

    • Marked as answer by Mark Zweig Wednesday, April 20, 2016 12:50 AM
    Friday, April 15, 2016 8:19 PM

All replies

  • $IndentationStrings = @('{','[','(','"',''')
    IMHO instead of ''' you have to use '''' or "'"


    my blog: http://shserg.ru/

    • Marked as answer by Mark Zweig Wednesday, April 20, 2016 12:50 AM
    Friday, April 15, 2016 8:19 PM
  • This is effectively what you have:

    Param(
    	[Parameter()]$IndentationStrings = @('{', '[', '(', '"', ''''),
    	[Parameter()]$OutdentationStrings = @('}', ']', ')', '"', '''')
    )

    Do not use blank parameter attributes,  Do not include "$false" attributes and do not place comments inside of a parameter declaration.

    A single quote is escaped with a single quote.

    Declaring parameters in this way serves no useful purpose.  If you just want to force an Advanced Function just do this:

    [CmdLetBinding()]
    Param(
    	$IndentationStrings = @('{', '[', '(', '"', ''''),
    	$OutdentationStrings = @('}', ']', ')', '"', '''')
    )


    \_(ツ)_/

    Friday, April 15, 2016 8:25 PM
  • Thanks for the quick response! This did indeed solve the problem. Thanks again, for taking the time to respond.
    Wednesday, April 20, 2016 12:50 AM