replacing files and folders ownership in home drives
When the previous network administrator migrated the user accounts from Novell to win 2003, he copied all the user's data into their new home drives (win 2003).
The problem is that he became the owner of the data and the user's disk quota works only with new files and folders.
Each user home drive is name as the username.
I needed a quick way to reassign proper ownership without manually scanning all the folders (1,600 users).
I had a couple of options like subinacl or chown. I opted for chown (Download Free Chown for Windows, Chown for Windows 1.0 Download).
It works well at the exception that it will give ownership of the root home drive to the student :(.
Not a problem as you can run it again and take ownership as an administrator.
Here are the 2 command lines to restore ownership of all the files and subfolders to a specific user:
chown -r student1 "D:\hwhs_users\students\student1\*"
chown administrator "D:\hwhs_users\students\student1\"
Quick and dirty solution: Scan the students folder, save the home drive name in an array then run Chown with these values:
Here is a small vbscript doing the job.
By the way, I use a nice free utility to find file and folders owned by a specific user: http://www.grimadmin.com/staticpages...php/file-owner
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
userPath = "D:\hwhs_users\students\"
For Each Subfolder in Folder.SubFolders
aSplit = Split (Subfolder.path, "\")
If UBound(aSplit) > 1 Then
user = aSplit(Ubound(aSplit))
Home_drive = Subfolder.path & "\"
cmd1 = "chown -r " & user & " " & chr(34) & home_drive & "*" &chr(34)
cmd2 = "chown administrator " & chr(34) & home_drive &chr(34)