I have a simple PowerShell function
function Foo($a, $b){
'$a = ' + $a
'$b = ' + $b
}
I invoke it by calling
Foo("dogs", "cat");
Everything I've read so far says the expected output is
$a = dogs
$b = cats
What I'm actually seeing is:
$a = dogs cat
$b =
If I rewrite my function as:
function Foo($a, $b){
'$a is ' + $a.GetType().Name;
'$b = ' + $b.GetType().Name;
}
The output is:
$a is Object[]
You cannot call a method on a null-valued expression.
At C:\WCMTeam\Percussion\Notifier\foo.ps1:4 char:7
+ '$b = ' + $b.GetType().Name;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Apparently $a and $b are being combined into a single array. What am I doing to cause this and how should I change it to get my expected result?