Mohammed Zubairu
Mohammed Zubairu

Reputation: 1

"A positional parameter cannot be found that accepts argument" Error Keeps coming

I have been trying to ask PowerShell to move certain files using a CSV file to indicate where, what needs to be moved to.

Here is my script:

import-csv sample1.csv  | foreach { copy-item $_.source\$_.file $_.destination\$_.file}

Here is the csv its meant to get the information from. image of the CSV of files i need to move.

Please, if anyone can help, that would be great.

Upvotes: 0

Views: 649

Answers (1)

G42
G42

Reputation: 10019

What's the full error? Assume it doesn't like the fact you're not using quotes:

Import-Csv sample1.csv  |
    ForEach-Object {
        Copy-Item -Path "$_.source\$_.file" -Destination "$_.destination\$_.file"
    }

Upvotes: 1

Related Questions