Link to home
Create AccountLog in
Avatar of Colchester_Institute
Colchester_InstituteFlag 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
Avatar of Justin Owens
Justin Owens
Flag of United States of America image

Are you wanting PowerShell to do the copying, or are you wanting PowerShell to call Robocopy?
Avatar of 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
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
That is cleaner than what I was doing... Well done, soostibi.
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
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
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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