Continuing from my comment...
Your code lines can be refactored to just this.
***Note:
I am using PowerShell variable squeezing to assign to the variable and output at the same time. That is not a requirement, just a choice.***
($NewArray = (Get-Content -Path 'D:\Temp\FileData.txt').Split(''))
# Results
<#
filetest.WIN.txt
Wed
Feb
10
12:00:37
2021
filetest.VID.avi
Wed
Feb
10
12:00:51
2021
#>
As I stated this is an array, and you can determine this, just by doing this
$NewArray.GetType()
# Results
<#
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
#>
Or doing this.
$NewArray[0]
# Results
<#
filetest.WIN.txt
#>
$NewArray[9]
# Results
<#
10
#>
Or is this your use case...
# The default display
(
$NewDataObject = Import-Csv -Path 'D:\Temp\FileData.txt' -Delimiter ' ' -Header FileName,
DayName,
Month,
DayNumber,
Time,
Year
)
# Results
<#
FileName : filetest.WIN.txt
DayName : Wed
Month : Feb
DayNumber : 10
Time : 12:00:37
Year : 2021
FileName : filetest.VID.avi
DayName : Wed
Month : Feb
DayNumber : 10
Time : 12:00:51
Year : 2021
#>
# Or forced to display as a table.
(
$NewDataObject = Import-Csv -Path 'D:\Temp\FileData.txt' -Delimiter ' ' -Header FileName,
DayName,
Month,
DayNumber,
Time,
Year |
Format-Table -AutoSize
)
# Results
<#
FileName DayName Month DayNumber Time Year
-------- ------- ----- --------- ---- ----
filetest.WIN.txt Wed Feb 10 12:00:37 2021
filetest.VID.avi Wed Feb 10 12:00:51 2021
#>