Powershell Script to copy files, source and destination input will be from two different files

Could some one please help me to loop and copy the files using powershell. My requirement is something like this

source inputfile contains:

C:\a\123
C:\b\abc
C:\ab\xyz
C:\xy\456

destination input file contains:

D:\2\123
D:\3\abc
D:\23\xyz
D:\ab\456

so the script should pick the first line from source file and first line from destination file to run a copy, likewise second line from source and second line from destination and so on....

As a example i have set the path to local drive, my requirement is on network share both the source and destination.

Have gone through the link "http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_28061268.html" which didn't help as the loop is overwriting all the files with the last source file, like C:\xy\456 is replacing all the destination files with the respective  name.
skss228Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
$source = get-content C:\source.txt
$dest = get-content C:\dest.txt

$count = ($source.Length - 1)
0..$count | % { Copy-Item -Path $($source[$_]) -Destination $($dest[$_])  -recurse  } 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
skss228Author Commented:
Thanks for this. Will test this and update the outcome.
0
skss228Author Commented:
Looks like this is working for me. Thanks a ton "Raheman Mohammed Abdul". Will run my final tests and mark this as solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.