Collin Stump Collin Stump - 7 months ago 44
PowerShell Question

Difference between [datatype] and [datatype[]]

When casting a datatype for a variable, what does the extra empty square brackets do?

For example, in defining a parameter for a function, I have noticed these two ways of casting a data type for that parameter:




What purpose does the empty square brackets in the second example serve?


The parameter in the second example accepts a list of strings (an array), the parameter in the first example only a single string.

This works in both cases:

-computername 'foo'

This works just in the second case:

-computername 'foo', 'bar'