I am trying to pass an array to a PowerShell script, but always get only one value. I chopped off my ass but can't find anything. All I have to do is pass the array to the script. Here is my code:
param($Location) ($location).count Foreach ($loc in $Location) { $loc }
Here is my command that I run:
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Unrestricted -File "C:\ParaTestingArray.ps1" -location Sydney,London
Here is the result:
1
Sydney
Throughout life, I cannot get it to capture another value in the array. I tried using
param([string[]]$Location)
I tried:
-location "Sydney","London" -location @(Sydney,London) -location Sydney London -location Sydney,London -location (Sydney,London)
What am I doing wrong?
source share