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,509 questions
0 comments No comments
{count} votes

2 answers

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

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


  2. Rich Matheisen 46,711 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.