0

When testing my PowerShell script in Visual Code I got the following error:

the term '​​​​​' is not recognized as the name of a cmdlet, function,

However, finally I tested the same code in ISE and I did not get the same error!

try {

    $file_name = Get-ChildItem -Path "F:\sample\uk-500-UTF.csv" 
    $csv_data = Import-Csv -Path $file_name.FullName -Delimiter ','

foreach ($line in $csv_data){
    $line
    break
}

}
catch{
    Write-Host "Ran into an issue: $($PSItem.ToString())"

}
Tesh
  • 29
  • 4
  • you saved the file in the wrong encoding. [“’” showing on page instead of “ ' ”](https://stackoverflow.com/q/2477452/995714) – phuclv Jul 13 '21 at 10:44
  • As aside, `Get-ChildItem` using a file's FullName is pointless because a file does not have child items.. Only folders and drives have them – Theo Jul 13 '21 at 10:46

1 Answers1

0

The issue seems to be with Visual Code. When I re-typed the same code, in another section of the same file, no error.

I hope this helps others who face a similar issue.

Tesh
  • 29
  • 4