I had a script that assumes something was an array, then failed when it wasn’t, so I needed a little checking:

$variable -is [system.array] will say True if it is an array, or False if not. You can also do $variable -isnot [system.array] and expect the exact opposite.

I chose to do this:

if($variable -isnot [system.array]){do some code expecting the $variable is not an array}


if($variable -is [system.array]){do some other stuff with $variable[0] being an array}