I tried to run line 10 to 16 but i get this error instead based on the snippet below. What should I do ?

PAYVINDRA SELVEN A/L TAMIL SELVEN 0 Reputation points
2024-03-28T15:33:54.5833333+00:00

User's image

User's image

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,059 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 40,816 Reputation points
    2024-03-28T17:33:45.72+00:00

    Parameter "Path" expects a path, not a filename.


  2. Rich Matheisen 44,776 Reputation points
    2024-03-28T18:20:11.8033333+00:00

    If $file.path is $null that would point to a problem in your CSV file. Is there a column named "path" in the CSV file? Are there any empty rows in the CSV file? Does any row in the CSV have an empty value in the "path" column?

    Also, if you're expecting a complete path (e.g., c:\directory\name.extension) to a file to be present in the "path" column of the CSV you should probably add -PathType Leaf to the Test-Path cmdlet.