Users have about 800 users with roaming profiles on a drive-- call it E:\User_Profiles (which is shared out to the network). Profiles are stored in the format:
And so forth. We're trying to do a wildcard copy of all files inside E:\User_Profiles to another disk.
xcopy E:\User_Profiles\*.* J:\User_Profiles\ /C /E /Y
Under each profile is the obligatory "My Documents" folder. All profiles are readable to the Administrators group-- except the "My Documents" folder. For whatever reason Administrators have no permission on each user's My Documents folder. This prevents copying with an "access denied" error.
We have to goto each profile, take ownership of My Documents, add permission for Administrators, then give ownership back to the user.
For 5 users this would be ok, but for 800 users this is an unworkable solution.
Can somone suggest a script that will recurse the entire E:\User_Profiles directory tree, and add the Administrators group with Full Control permissions to every "My Documents" folder in the tree?
If permissions cannot be added without taking ownership first, the script would have to detect the current owner (which appears to always be the user of the profile), temporarily change owner to Administrators, add full control permissions for Administrators, then return ownership to the original owner.
Suggestions, please. Thanks in advance.