1

The following script:

cls
function test_me([string]$testVar, $my_array)
{
    Write-Host $testVar
}

$test_array = "a","b"
test_me "z", $test_array

Produces the following result:

z System.Object[]

I only want to reference $testVar

Why is System.Object[] getting returned to the Write-Host?

ray
  • 8,521
  • 7
  • 44
  • 58

1 Answers1

4

This error is probably as old as PowerShell... You call function like method, and it won't work like that, try this instead:

test_me 'z' $test_array

HTH Bartek

BartekB
  • 8,492
  • 32
  • 33