In a recent customer project, we have redirected the user’s personal Desktop, Documents and Favorites folders to the cloud using OneDrive. Users can get to their files from anywhere and the files are safe in OneDrive if anything happens to the devices.
Configure folder redirection in 3 steps
The configuration requires 3 steps:
- Prevent users from changing the location of their OneDrive folder
- Create an environment variable for the OneDrive folder
- Configure redirection of Documents, Desktop & Favorites folders to OneDrive
1. Prevent users from changing the location of their OneDrive folder
We will configure a group policy to make sure users sync their OneDrive to the default location and do not change the location of their OneDrive folder.
The group policy is located under:
User Configuration\Policies\Administrative Templates\OneDrive\Prevent users from changing the location of their OneDrive folder
2. Create an environment variable for the OneDrive folder
Group Policy won’t let us redirect known folders directly to a different location under %userprofile%, so we need to create a new environment variable that contains the location of the folder under %userprofile%.
We’ll use item-level targeting in this environment variable to prevent folders from being redirected until the folder has been created by the sync client.
Under “User Configuration\Preferences\Windows Settings” create a new Environment variable called “OneDriveSync” and set the value to “%userprofile%\”.
e.g. %userprofile%\OneDrive – ranari
In the common tab check the box “Item-level targeting” and define a new item that matches the folder you have defined before “%userprofile%\”.
3. Configure redirection of Documents, Desktop & Favorites folders to OneDrive
Under “User Configuration\Policies\Windows Settings\Folder Redirection”, go to Properties and enable the setting “Basic – Redirect everyone’s folder to the same location” and set the Target folder location to “Redirect to the following location”. For the Root Path type in “%OneDriveSync%\Documents”.
On the Settings tab, clear the “Move the contents of Documents to the new location” check box.
Leaving this setting enabled could result in data loss when the contents of the Documents folder is merged with the OneDrive folder, if there are files with the same name in both locations.
Configure group policies similarly to redirect the Desktop or Favorites area.
Note that it is not supported to have existing content automatically migrated by Group Policy to the OneDrive folder. With automatic file migration, there is a potential for data loss in cases where there are files in both locations that have matching file names.
Once the redirect to OneDrive is in place, we’ll need to migrate the user’s data from the original location on their local disk to the OneDrive folder.
Keep in mind that as new users and computers come online over time, users may still save files to their Documents folder before they configure the OneDrive sync client, and these files would then need to be moved to the OneDrive folder after the redirect takes place.
After everything is set up, here is how the user experience will look like:
- The user logs in to Windows and gets the OneDrive set up page.
- He types in his e-mail address firstname.lastname@example.org and clicks Sign in.
- If a new login window appears, types in the credentials again and clicks ok. (after adding the sites through GPO in the IE zones this step might not be necessary)
- Go through the Wizard without changing any settings, click Next every time.
- The Folder Redirection will be configured automatically on the next reboot.
- All the existing files need to be manually copied to the new locations. Or they can be copied via script, which I will cover in a separate article.