I’ve got the following code:
function printVars($var1, $var2)
{
Write-Host "var1: $var1"
Write-Host "var2: $var2"
}
printVars ('asdf', 'qwer')
It produces this result:
var1: asdf qwer
var2:
I am expecting this:
var1: asdf
var2: qwer
Why is it doing that and how do I get it to do what I want?
Because
('asdf','qwer')gets treated as an array, so$var1gets the array and$var2is empty.Do
printVars 'asdf' 'qwer'Even if you don’t have the parantheses and have just the comma, it is an array.
Try this: