Copying of Specfic folders from a user profile to a new profile Server
-
Thursday, January 17, 2013 3:49 AMHi All,
We are in the process of copying user profiles to a new Server but the new folder structure is different and I dont want all the folders from the old profile copied over.
for example we want to copy data from the Path:
\\profileS01\ctxMFMTSHome$\%USERNAME%\My Documents to their home drive located on \\homedriveS01\Profiles\%USERNAME%\ My Documents
\\profileS01\ctxMFMTSHome$\%USERNAME%\Desktop to go to the new Profile Server \\homedriveS01\UserData\%USERNAME%\Desktop
\\profileS01\ctxMFMTSHome$\%USERNAME%\Favourites to go to the new Profile Server \\homedriveS01\UserData\%USERNAME%\Favourites
\\profileS01\ctxMFMTSHome$\%USERNAME%\Application Data\Microsoft\Outlook to \\homedriveS01\UserData\%USERNAME%\AppData\Roaming\Microsoft\outlook
there are a few more folders that have to be copied.
I have to deliver this for about 1000 users. I am trying to get a script that will do this.
any assistance is welcome.
Thankyou in advance.
All Replies
-
Thursday, January 17, 2013 5:15 AMUse Group Policy folder redirection. It is efficient, automatic and works across operating system versions.
¯\_(ツ)_/¯
-
Thursday, January 17, 2013 5:20 AM
We are using group Policy to redirect user profiles to the new locations.
I have to copy the old user data here.
The old profile Server will be decomissioned after the move.
with robocopy I can do this on a per user basis. If I can use a text file that feeds in the list of \%USERNAME%\ that would be great but Robocopy wouldnt do it.
Cheers,
-
Thursday, January 17, 2013 5:32 AM
PowersHELL
$accounts=cat accounts.txt foreach($accoutn jnj $accounts){ ROBOCOPY "\\profileS01\ctxMFMTSHome$\$account\My Documents" "\\homedriveS01\Profiles\$account\My Documents" }
Add as many lines as you need in the loop. Add any switces you need.
¯\_(ツ)_/¯
- Edited by jrvMicrosoft Community Contributor Thursday, January 17, 2013 5:33 AM
-
Thursday, January 17, 2013 10:14 PM
Giving this a try now.
Thanks for your assistance.
-
Friday, January 18, 2013 1:44 AM
Hi<o:p></o:p>
I get the
following error. when executing the line <o:p></o:p>foreach($accounts
jnj $accounts){
ROBOCOPY /COPYALL /SEC
"\\S01\ctxMFMTSHome$\$accounts\MyDocuments"
"P:\HomeDirs\$account\My Documents"
}<o:p></o:p>I ran the
script by the line and it come up with the error shown below. It also adds all
the names from the text file into a single line when executing the command. <o:p></o:p>
PS P:\temp> $accounts=cat accounts.txt
PS P:\temp> $accounts
jpp
qmmtest5
SebastianS
PS P:\temp> foreach($accounts jnj $accounts){
Missing 'in' after variable in foreach loop.
At line:1 char:19
+ foreach($accounts <<<< jnj $accounts){
+ CategoryInfo : ParserError: (InToken:TokenId) [],
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingInInForeach<o:p></o:p>
Thanks
- Edited by JPPhilip Friday, January 18, 2013 4:31 AM
-
Friday, January 18, 2013 1:55 AM
FOREACH( $ACCOUNT IN $ACCOUNTS)
SPELLING SPELLING SPELLING!!!
¯\_(ツ)_/¯
- Edited by jrvMicrosoft Community Contributor Friday, January 18, 2013 2:55 AM
-
Friday, January 18, 2013 2:02 AMModerator
That's not correct either. It should be:
foreach ( $account in $accounts ) {
Bill
-
Friday, January 18, 2013 2:55 AM
That's not correct either. It should be:
foreach ( $account in $accounts ) {
Bill
Good catch - I fixed it - thanks.¯\_(ツ)_/¯
- Marked As Answer by JPPhilip Friday, January 18, 2013 4:18 AM
-
Friday, January 18, 2013 3:45 AM
Thanks Guys, I am almost there
I got it to work for one line, but it does not work when I have more than one line. It does not work as expected. It copies data across all the users
but stops executing after the first line.
$accounts=cat accounts.txt
foreach ($accounts in $accounts)
{ ROBOCOPY /COPYALL /SEC "\\S01\ctxMFMTSHome$\$accounts\My Documents" "P:\HomeDirs\$account\My Documents" }
{ ROBOCOPY /COPYALL /SEC "\\S01\ctxMFMTSHome$\$accounts\Desktop" "P:\UserData\$account\Desktop" }
{ ROBOCOPY /COPYALL /SEC "\\S01\ctxMFMTSHome$\$accounts\Favourites" "P:\HomeDirs\$account\Favourites" }
ROBOCOPY /COPYALL /SEC "\\S01\ctxMFMTSHome$\$accounts\Desktop" "P:\UserData\$account\Desktop"
ROBOCOPY /COPYALL /SEC "\\S01\ctxMFMTSHome$\$accounts\Favourites" "P:\HomeDirs\$account\Favourites"
- Edited by JPPhilip Friday, January 18, 2013 4:32 AM
-
Friday, January 18, 2013 3:51 AM
Dumping all of that to the screen is of no help.
Please just state you problem.
¯\_(ツ)_/¯
-
Friday, January 18, 2013 3:53 AM
Last time. Look at the line:
foreach ($accounts in $accounts)
It is supposed to say:
foreach ($account in $accounts)
The difference is quite obvious.
¯\_(ツ)_/¯

