Script to update registry with new folder redirection location

I am currently in the process of moving folder redirected my documents that are located on one server to another, i have already finished a script to move the data, restructure everyone's folder so that their previous my documents folder was "\\servername\share\%username%" to their new folder location being "\\newservername\share\%username%\Documents" and give ownership and full control over each individuals folder which works flawlessly, but when changing group policy to the new location and a user logs in it doesnt pick up and refresh the new location and instead trys to use the old location and then the user logs off and then back on and it is still the same, i have included a logon script through AD to do a gpupdate although the user still has the old location after that first initial login and has to log off and back on and then it works and the user has the new location.

I am looking for some way of pushing a script out to about 1200 machines to search and change the locations in the registry so when the user logs on the very first time he has the new location and it is then handled through gpo after that. Pushing a script out is not a big deal to 1200 machines because we use System Center Configuration Manager 2007 and that would be very easy, the only problem im having is finding a script to search through all of the users registry keys and replace the old location with the new location because the script will actually need to break the old location down and then rebuild it. I did find regtkt from http://download.cnet.com/Registry-Toolkit/3000-18512_4-10033761.html?tag=mncol&cdlPid=10909718  but it only replaces data in the registry and it has no way of looking at the existing keys and building them from \\oldservername\share\username  to \\newservername\share\username\Documents     which it can replace the new server name but cant append the Documents to the end.

In our environment there are about 2500 users with folder redirected my documents that will need moving.
MightyElectroAsked:
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.

Encrypted1024Commented:
How did you do folder redirection the first time? Why didn't you just use Group Policy Folder redirection? Or did you? Maybe the old policy is still enabled that is why your script doesn't work. Group Policy Folder redirection will even move the files from the old location to the new one without scripts (this can have issues of its own, but the feture is there).
0
MightyElectroAuthor Commented:
We are using Group Policy and we are using the exact same GPO as we did originally. I have tried Move Contents feature although it does not work at all for various reasons including but not limited to being very slow if the folder is large. In-order for move contents feature to work the user has to login on the same machine they have been forever or at least one that knew their last location. In our environment that's impossible since they are students and they don't have assigned machines, if a policy is setup to move the contents to the new server and a user logs in to a machine they have never logged in to before then the machine copies the blank documents folder on that machine because the machine sees that  the previous location was on the local machine. The only script I have or will use with folder redirection is a one time deal where i do a mass move to the new server, reset all the security settings and then if possible get a script to do a mass change on every machine so that there isn't any confusion and that script would be the one im needing to change all of the users registry keys so that there instantly the new server location and the user doesn't have to logon and back off numerous times so that the user gets the latest group policy update.
0
pubeheedCommented:
The other way you could do this is a bi bang type move

Basically copy the data across to the new location through a week or so and then do a final copy on the night to reduce the amount of data to be copied - I would suggest using robocopy for this task.

Once everything is copied to the new location ensure that strict name checking is turned off on the new servers and then update DNS so the OLD server name points to the new server ip address.

This will only work if there are no other services on the old server that you need to access i.e. other shares as obviously anyone trying to get those shares will be redirected to the new server.

I know this doesn't fix the GPO problem but thought I would throw it in as a bit of a left field suggestion.

You could also fudge it by rollling out a temp hostfile to the machine for the first login that woudl stop the double logging - basically have a script that takes a copy of the old hosts add the file in it that redirects the old name to the new servers ip and then wen they login the next time it chnages it back as the policy will have updated.  

Good luck

0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

MightyElectroAuthor Commented:
thanks pubeheed

We had thought of that as well but really wanted a way to just seamlessly update every location for everyone's documents and a dns entry that pointed the old server name to the new ip didn't really help us in putting the new Documents folder on path to the end and our new server will be using DFS namespaces.

Although after digging I figured out how to accomplish this fairly easily. I created a logon script and applied it to the users logon account (not a group policy logon script) with the following in the cmd file.

*********************
@echo off
regedit /S \\domainname\netlogon\personal.reg
exit
*********************

within the personal.reg file i have the following.

*********************
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
"Personal"="\\\\servername\\share\\%username%\\Documents"
*********************

within the personal.reg file I had found on 1 windows 7 machine (mine) when i first created it, it has hex values instead of plain text for the path which looked similar to this

"Personal"=hex(2):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,6e,00,5c,00,\
  73,00,74,00,75,00,64,00,65,00,6e,00,74,00,73,00,24,00,5c,00,36,00,30,00,30,\
  00,30,00,00,00,25,00,00,00,73,00,65,00,00,00,6e,00,61,00,6d,00,65,00,25,00,\
  5c,00,00,00,6f,00,63,00,75,00,00,00,65,00,6e,00,00,00,73,00,00,00

the only difference between the window 7 machines is that one is 64bit which is mine and the other 32bit, other than that idk and both work just fine on either. To get the hex value you need to export the key from regedit utility.

This script updates the personal key or the Documents key just in time for explorer to set the shell location and then after this script executes group policy is updated, which i have found no matter what the group policy is set to this script takes effect first even if the shell location changes after this reg file gets added to the registry, i would think microsoft would make the group policy refresh before windows explorer uses any policy settings and instead group policy is always late and doesn't take effect until after the user logs off and back on. This is probably not recommend but its a sneaky way of injecting the new location at the perfect time. After a while we will just remove the script and everything will be on the new server and on its new path.

I wanted to share this solution because i always hate when people on the internet say they fixed it and then don't ever share the solution for other people that have the same situation or problem.
0
JohnGerhardtCommented:
Hi MightyElectro,
Are you all sorted?
Popped by a little late, but my $0.02 worth...
Was going to suggest that you use DFS in the future..! But sounds like you are now there, this will make it so much easier to move these files in the future.
Check out the registry key HKCU\..\Shell Folders - http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_21997835.html might be worth throwing the path in there just to be sure.
On a side note: In order to make sure that the %username% is expanded then you need to make sure that the value is an "Expandable String Value" (REG_EXPAND_SZ) and not a normal "String" (REG_SZ). But as you exported them from a working machine then it is bound to be correct...
I have had this problem a number of times, (banging my head against the wall with GPOs...!) a DFS setup although often a large amount of work to get implemetated really helps....
John
 
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
MightyElectroAuthor Commented:
None
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
Active Directory

From novice to tech pro — start learning today.