Determined a fix:
Before referencing the index to an index… make it a string first:
$c=$MergeColHeaders[$i]; write-host $ct:
t $Update[0].$c
Typing:
PS C:\Projects\mySQL\HardWay> $Primary.gettype()
IsPublic IsSerial Name BaseType
True True Object System.Array
PS C:\Projects\mySQL\HardWay> $MergeColHeaders.gettype()
IsPublic IsSerial Name BaseType
True True Object System.Array
Hard-coded Test:
PS C:\Projects\mySQL\HardWay> $MergeColHeaders[1]
TRACKING
PS C:\Projects\mySQL\HardWay> $Primary[0].tracking
resp
Desired Attempt:
PS C:\Projects\mySQL\HardWay> $Primary[0].$MergeColHeaders[1]
Cannot index into a null array.
At line:1 char:1
- $Primary[0].$MergeColHeaders[1]
-
- CategoryInfo : InvalidOperation: ( , RuntimeException
- FullyQualifiedErrorId : NullArray
I’m a “recovering programmer” and think my coding days are tainting my ability to understand PS.
I feel like the above samples should prove ‘if A=B and B=C then A=C’ but, clearly, PS says otherwise.
My assumption is I’m missing something obvious (which is usually my case!) but, I’ve googled for 1.5 days and have gotten no closer to unraveling this mystery. This is part of a larger conundrum but, I think it starts here.
Please let me know what else you may need from me.