This is a stripped down version of the code I need to run. I've been able to determine, with this test code, that it's happening as soon as the array enters the function. Am I doing something wrong when I pass the array? This seems like it should be simple, but I'm stuck. Doing Return ,$List doesn't make any difference.
Script:
function ProcessSkills{
param([Object[]]$List)
Write-Host $List.GetType()
Write-Host $List.Count
Write-Host $List
$List += 11
Write-Host $List.GetType()
Write-Host $List.Count
Write-Host $List
return $List
}
$skillList = @()
Write-Host
Write-Host "Start"
Write-Host
Write-Host $skillList.GetType()
Write-Host $skillList
Write-Host $skillList.Count
$newSkillList = ProcessSkills -$skillList $skillList
$skillList = $newSkillList
Write-Host $skillList.GetType()
Write-Host $skillList
Write-Host $skillList.Count
$newSkillList = ProcessSkills -$skillList $skillList
$skillList = $newSkillList
Write-Host $skillList.GetType()
Write-Host $skillList
Write-Host $skillList.Count
$newSkillList = ProcessSkills -$skillList $skillList
$skillList = $newSkillList
Write-Host $skillList.GetType()
Write-Host $skillList
Write-Host $skillList.Count
Output:
Start
System.Object[]
0
System.Object[]
1
-
System.Object[]
2
- 11
System.Object[]
- 11
2
System.Object[]
1
-- 11
System.Object[]
2
-- 11 11
System.Object[]
-- 11 11
2
System.Object[]
1
--- 11 11
System.Object[]
2
--- 11 11 11
System.Object[]
--- 11 11 11
2
$is not part of the parameter name, change all instance ofProcessSkills -$skillList $skillListtoProcessSkills -List $skillList