Copying List of Files Through Powershell

Posted by Driftpeasant on Server Fault See other posts from Server Fault or by Driftpeasant
Published on 2012-06-16T00:23:58Z Indexed on 2012/06/16 3:17 UTC
Read the original article Hit count: 171

Filed under:

So I'm trying to copy 44k files from one server to another.

My Powershell script is:

Import-CSV f:\script\Listoffiles.csv | foreach $line {Move-item $_.Source $_.Destination}

With the Format for the CSV:

Source, Destination  
E:\folder1\folder2\file with space.txt, \\1.2.3.4\folder1\folder2\file with space.txt

I keep getting:

A positional parameter cannot be found that accepts argument '\\1.2.3.4\folder1\folder2\file'.
At line:1 char:10
+ move-item <<<<  E:\folder1\folder2\file with space.txt \\1.2.3.4\folder1\folder2\file with space.txt
    + CategoryInfo          : InvalidArgument: (:) [Move-Item], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.MoveItemCommand

So I've tried putting "s around both paths, and also 's, and I still get either Move-Item: Could not find a part of the path errors.

Can anyone help me?

© Server Fault or respective owner

Related posts about powershell