Migrating User Profiles & Resetting Permissions - Powershell



I recently begun to look at migrating user profile data for a client. Existing user profiles were hosted on a Windows file server and these profiles were being used in conjunction with folder redirection and offline files. After discussions the client decided to move to Work Folders (native to Windows Server 2012). Work folders requires users are owners of their "workfolder" (see here) and the existing data had many broken SIDs and unnecessary permissions set so it was a requirement to strip everything and start again.

'Special Folders' used by folder redirection (Desktop, Favorites, Documents) were completely broken and no user other than the owner had read access to them, therefore copying the data would prove difficult. I attempted to initially use RoboCopy for the task however this fell over when trying to copy these special folders. The client had an install of Dell Secure Copy on an old file server so i was able to leverage that, i believe it copies at the disk level and does not honor OS NTFS permissions.

The below script is what i ended up coming up with for the copy. The client would be migrating individual users initially therefore the script is prompting for paths and usernames but the code could easily be modified to facilitate groups of users.

The below code basically:

  1. Reads in values for Source and Destination
  2. Copies data to destination
  3. Sets the AD user to modify and makes them the owner.

Hopefully this script helps someone in a similar position.

Cheers



Labels: