Hi, my problem is a bit strange and I don’t understand why.
Basically I have a CSV with every day of the year as column and some numeric values inside, I’d like to select specific values using a for loop.
In my array here I put only the days of January for semplicity.
$VenditeGrezze = "C:\Users\bm607134\OneDrive - Brescia Mobilità S.p.A\Desktop\bk tvm"
$FileAggregato = Get-ChildItem -Path $VenditeGrezze -Include "*Vendite*" -Recurse |
Sort-Object LastWriteTime |
Select-Object -Last 1
$Aggregato = Import-Csv -Path $FileAggregato -Delimiter ';' -ErrorAction Stop
$Calendario2 = @(‘2026-01-01’,’2026-01-02’,’2026-01-03’,’2026-01-04’,’2026-01-05’,’2026-01-06’,’2026-01-07’,’2026-01-08’,’2026-01-09’,’2026-01-10’,’2026-01-11’,’2026-01-12’,’2026-01-13’,’2026-01-14’,’2026-01-15’,’2026-01-16’,’2026-01-17’,’2026-01-18’,’2026-01-19’,’2026-01-20’,’2026-01-21’,’2026-01-22’,’2026-01-23’,’2026-01-24’,’2026-01-25’,’2026-01-26’,’2026-01-27’,’2026-01-28’,’2026-01-29’,’2026-01-30’,’2026-01-31’)
$ArrayName2 = "'" + $Calendario2[2] + "'"
Write-Output $ArrayName2
Write-Output $Aggregato[2].$ArrayName2
Write-Output $Aggregato[2].'2026-01-03'
The import is successful, what I don’t understand is this:
If I write
Write-Output $Aggregato[2].'2026-01-03'
It works, while if I write
Write-Output $Aggregato[2].$ArrayName2
Which should be the same thing it doesn’t
If I print $ArrayName2 I see ‘2026-01-03’ like it is supposed to
Am I missing something?