Get-ChildItem, path

Hi, I have a problem with Get-ChildItem, maybe I am using the wrong syntax or I am misinterpreting how it works.

Tha case is simple, I have 2 folders on the Desktop, “Vendite” and “New folder”, both folders contain the same CSV files. I need to import the last edited file on the folder “Vendite” but when I try to select it it selects also the one in the other folder.

This is one of the files (I will have a new file each day, so that is why I’m filtering): SDD_380712_020_021_IBACDC_250529_00332.csv_20250529-043101.sav

$VenditeGrezze = "C:\Users\AdminATLAS\Desktop\Vendite" #the path with my files

$fileCDC = Get-ChildItem -Path $VendteGrezze -Include "*IBACDC*" "*.csv*" -Recurse
        Sort-Object LastWriteTime | 
        Select-Object -Last 1

Write-Output $fileCDC

$Data = Import-Csv -Path $FileCDC -Delimiter '|' -ErrorAction Stop

Thank you in advance

You have a typo in your variable names … $VenditeGrezze vs $VendteGrezze. Is it just from copying the code here or do you have it in your original code as well?

What IDE/Code editor are you using?

I just discovered that, I’m using Powershell 5.0. I was about to delete the topic. Thank you

So you don’t use any code editor? I’d recommend using VSCode including the extension ErrorLens. It helps preventing errors like that. :point_up::wink: