Accessing an array, not providing expected results

The following is true when run within PS 5 or PS 7.

$_old = Get-Content F:\TESTING\_Match_Criteria.txt
$_old[0] # Why blank output?

<#
The "_Match_Criteria.txt" is populated with 
one-hundred and fifty-four separate lines.
Within this script, just using $_old on a line by itself,
will output every line of data; on its own 'separate' line.

However, when $_old[0] is used within the same above script,  
the output will be a blank line.

Your thoughts?
#>

I cannot reproduce your issue. :man_shrugging: I get the expected output. It might be something with your input file.

You mentioned a script. You may share this script. :wink:

@Olaf – Thank you for the quick response, the contents of the input-file, --with the same name is below …

01_91_8_IPC1_NVR16-8580_
01_93_8_IPC3_NVR16-8580_
01_94_8_IPC4_NVR16-8580_
02_92_8_IPC2_NVR16-8580_
02_95_8_IPC5_NVR16-8580_
03_91_8_IPC1_NVR16-8580_
03_93_8_IPC3_NVR16-8580_
03_95_8_IPC5_NVR16-8580_
04_100_8_IPC10_NVR16-8580_
04_92_8_IPC2_NVR16-8580_
04_93_8_IPC3_NVR16-8580_
04_97_8_IPC7_NVR16-8580_
05_91_8_IPC1_NVR16-8580_
05_93_8_IPC3_NVR16-8580_
05_96_8_IPC6_NVR16-8580_
06_92_8_IPC2_NVR16-8580_
06_94_8_IPC4_NVR16-8580_
07_93_8_IPC3_NVR16-8580_
07_94_8_IPC4_NVR16-8580_
08_93_8_IPC3_NVR16-8580_
08_94_8_IPC4_NVR16-8580_
09_93_8_IPC3_NVR16-8580_
09_95_8_IPC5_NVR16-8580_
1_11_IPC1_NAPA_
1_IPC1_NAPA_
10_94_8_IPC4_NVR16-8580_
100_0_IPC10_NVR16-8580_
100_2_IPC10_NVR16-8580_
100_3_IPC10_NVR16-8580_
100_8_IPC10_NVR16-8580_
107_0_IPC1_NAPA_
107_1_IPC1_NAPA_
107_7_IPC1_NAPA_
107_IPC1_NAPA_
108_0_IPC2_NAPA_
108_1_IPC2_NAPA_
108_6_IPC2_NAPA_
108_7_IPC2_NAPA_
108_IPC2_NAPA_
11_95_8_IPC5_NVR16-8580_
140_8_IPC2_NVR16-8580_
141_2_IPC3_NVR16-8580_
141_6_IPC3_NVR16-8580_
141_8_IPC3_NVR16-8580_
142_6_IPC4_NVR16-8580_
142_8_IPC4_NVR16-8580_
143_6_IPC5_NVR16-8580_
143_8_IPC5_NVR16-8580_
144_6_IPC6_NVR16-8580_
144_8_IPC6_NVR16-8580_
145_8_IPC7_NVR16-8580_
147_8_IPC9_NVR16-8580_
155_3_IPC1_NAPA_
155_IPC1_NAPA_
156_3_IPC2_NAPA_
156_IPC2_NAPA_
2_11_IPC2_NAPA_
2_20_3_IPC4_NVR16-8580_
2_IPC2_NAPA_
20_3_IPC4_NVR16-8580_
20_8_IPC4_NVR16-8580_
21_3_IPC5_NVR16-8580_
21_8_IPC5_NVR16-8580_
3_2_IPC3_VICTORIA_
3_21_3_IPC5_NVR16-8580_
3_8_IPC3_VICTORIA_
33_0_IPC1_VICTORIA_
33_11_IPC1_NAPA_
33_IPC1_NAPA_
34_11_IPC2_NAPA_
34_IPC2_NAPA_
35_2_IPC3_VICTORIA_
36_2_IPC4_VICTORIA_
37_0_IPC5_VICTORIA_
37_2_IPC5_VICTORIA_
37_3_IPC5_VICTORIA_
37_8_IPC5_VICTORIA_
38_2_IPC6_VICTORIA_
38_3_IPC6_VICTORIA_
38_8_IPC6_VICTORIA_
4_21_3_IPC5_NVR16-8580_
4_8_IPC4_VICTORIA_
5_2_IPC5_VICTORIA_
5_37_3_IPC5_VICTORIA_
5_8_IPC5_VICTORIA_
6_38_3_IPC6_VICTORIA_
6_8_IPC6_VICTORIA_
6_96_8_IPC6_NVR16-8580_
7_21_8_IPC5_NVR16-8580_
7_94_8_IPC4_NVR16-8580_
75_0_IPC1_NAPA_
75_3_IPC1_VICTORIA_
75_6_IPC1_NVR16-8580_
75_8_IPC1_NVR16-8580_
75_8_IPC1_VICTORIA_
76_0_IPC2_NAPA_
76_3_IPC2_VICTORIA_
76_8_IPC2_NVR16-8580_
76_8_IPC2_VICTORIA_
77_2_IPC3_NVR16-8580_
77_2_IPC3_VICTORIA_
77_3_IPC3_VICTORIA_
77_8_IPC3_NVR16-8580_
77_8_IPC3_VICTORIA_
78_2_IPC4_VICTORIA_
78_3_IPC4_VICTORIA_
78_8_IPC4_NVR16-8580_
78_8_IPC4_VICTORIA_
79_0_IPC5_NVR16-8580_
79_2_IPC5_VICTORIA_
79_3_IPC5_VICTORIA_
79_6_IPC5_NVR16-8580_
79_8_IPC5_NVR16-8580_
79_8_IPC5_VICTORIA_
8_20_8_IPC4_NVR16-8580_
8_95_8_IPC5_NVR16-8580_
80_2_IPC6_NVR16-8580_
80_3_IPC6_VICTORIA_
80_6_IPC6_NVR16-8580_
80_8_IPC6_NVR16-8580_
80_8_IPC6_VICTORIA_
83_0_IPC9_NVR16-8580_
83_3_IPC9_NVR16-8580_
83_8_IPC9_NVR16-8580_
84_3_IPC10_NVR16-8580_
84_8_IPC10_NVR16-8580_
91_2_IPC1_NVR16-8580_
91_3_IPC1_NVR16-8580_
91_8_IPC1_NVR16-8580_
92_2_IPC2_NVR16-8580_
92_3_IPC2_NVR16-8580_
92_8_IPC2_NVR16-8580_
93_0_IPC3_NVR16-8580_
93_2_IPC3_NVR16-8580_
93_3_IPC3_NVR16-8580_
93_8_IPC3_NVR16-8580_
94_0_IPC4_NVR16-8580_
94_2_IPC4_NVR16-8580_
94_3_IPC4_NVR16-8580_
94_8_IPC4_NVR16-8580_
95_1_IPC5_NVR16-8580_
95_2_IPC5_NVR16-8580_
95_8_IPC5_NVR16-8580_
96_2_IPC6_NVR16-8580_
96_3_IPC6_NVR16-8580_
96_6_IPC6_NVR16-8580_
96_8_IPC6_NVR16-8580_
97_2_IPC7_NVR16-8580_
97_3_IPC7_NVR16-8580_
97_8_IPC7_NVR16-8580_
98_8_IPC8_NVR16-8580_
99_2_IPC9_NVR16-8580_
99_3_IPC9_NVR16-8580_
99_8_IPC9_NVR16-8580_

Hmmm … and what should I do with that? :thinking: :man_shrugging:

@Olaf – I wasn’t sure what you meant about “it being something with the input”, I provided the content in-case you saw something I didn’t. Really odd that both PS 5 and 7 are doing the same thing. I’m not sure where-else to look.

If anything comes to mind, please post

Respect

What’s with the script you mentioned? What’s the encoding of the input file? How is it created?

… and BTW: since you copied the text of the input file here it is not the same as your input file anymore. :man_shrugging:

That was the script with the multi-line comment below the code; within the preformatted code block.

The creation of F:\TESTING_Match_Criteria.txt was a redirected output: _NVR_Filename_Prefixes_TESTING.ps1 >> F:\TESTING\_Match_Criteria.txt

I’ll try to put all of this into one ps1, without using the redirected file. Thank you for having a look.

It appears the actual ps1 file running the code is at fault. After copying the ps1 contents to a freshly named ps1, all is functioning as intended.