Avatar of Colchester_Institute
Colchester_Institute
Flag for United Kingdom of Great Britain and Northern Ireland asked on

POWERSHELL COMMAND FOR COPY-ITEM

Hi there

I'm looking for a powershell command that is equivalent to the following dos command:

 for /f %%N in (test.txt) DO CALL robocopy "D:\User Areas\Reenrolled\%%N\My Documents" "\\SERVER\E$\Area\%%N\My Documents\sub folder" /E /R:0 > C:\diditwork.txt

I'm sure its something to do wiht assigning a variable somewhere  but my mind has gone blank

Many thanks
PowershellScripting LanguagesWindows Server 2003

Avatar of undefined
Last Comment
Colchester_Institute

8/22/2022 - Mon
Justin Owens

Are you wanting PowerShell to do the copying, or are you wanting PowerShell to call Robocopy?
Colchester_Institute

ASKER
Powershell to do the copying...Have a list of names in the text file that need to be used so for example the Text file might contain:
DrUltima
Joeblogs
MickyMouse

and i need those names to be used as the areas that are being copied is:

Server1\E:\Users\<Txt file name here eg Joeblogs>\My Docs

and its being copied to

Server2\E:\Users\<Txt file name here eg Joeblogs>\My Docs\Subfolder

Like i said i know i can do this using robocopy i'd just rather start using Powershell to do such things and am sure i'm just being dense...Its Friday arvo! LOL
SOLUTION
soostibi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Justin Owens

That is cleaner than what I was doing... Well done, soostibi.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Colchester_Institute

ASKER
Hi soostibi

That works perfect. ty..Just one more question incase i decide to add it or change it later.....How do i either make it move the original files or once its copied them delete the original files?

Many thanks
Colchester_Institute

ASKER
Also one thing i did notice.....Any subfolders weren't copied over...The files were but not the folders so the Files just ended up in one big folder for each user
ASKER CERTIFIED SOLUTION
soostibi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Colchester_Institute

ASKER
The role of the sub folder is basically that i'm moving data from what was an old domain and placing it into the users area on the new domain.  But what them to easily be albe to find the data from the old one :-) Many thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.