Change file ownership of only admin-owned files

I want to find a way to change the ownership of entire folders and their contents to a specific user, but only change ownership where files and folders are currently owned by "BUILTIN\Administrators."  I don't want to change existing ownerships if some files within these folders are already owned by specific users.

Does anyone know of a way of accomplishing this?  

I am guessing that the ownership was set to administrators when file servers were changed, and certain file attributes were lost in the file transfer.
LVL 6
HomerTNachoCheeseAsked:
Who is Participating?
 
HomerTNachoCheeseAuthor Commented:
Let's say I want to run through the Q: drive to find all the admin-owned files and set ownership to HomerT:

Step 1:
FileList (http://www.jam-software.com/freeware/index.shtml)
Run the command filelist /owners /fullpath q: >owners.csv

Step 2:
Open the csv file in Excel, sort by owner, delete rows we will not be changing.
Delete all columns except for Full Path (which will be column A).

Step 3:
For column B, set a formula based on column A.  So, if A1 was my first file name, then B1 would have this formula:
=CONCATENATE("icacls """,A2,""" /setowner HomerT")
I need to have double quotes around my file names, so """ is how I get a double quote to appear in the string.
For every file listed, paste this formula.

Step 5:
Copy and paste column B into Notepad.  Entries should look similar to this after pasting:
icacls "q:\Calibration Records\CALTOOLS\CF001.doc" /setowner HomerT
icacls "q:\Calibration Records\CALTOOLS\CF002.doc" /setowner HomerT
icacls "q:\Calibration Records\CALTOOLS\CF003.doc" /setowner HomerT
icacls "q:\Calibration Records\CALTOOLS\CF005.doc" /setowner HomerT

Step 6.
Save as a batch file and run it.

This assumes that you have icacls, which is in Windows 7.  Other operating systems may have other commands, or you may need to download some similar tool.  This process does not force ownership change, but it appears to work for me.
0
 
Wilder_AdminCommented:
The only answer on this question i have is to use a third party tool like http://helgeklein.com/setacl-studio/

Here you can define filter rules to set the new acl´s
0
 
HomerTNachoCheeseAuthor Commented:
Wilder - your solution may work, but I want to try something free first.  I was taking a look at subinacl.exe, but I am not sure if that would work.  Points should come your way after I collect more feedback from others :)

I suppose a script that I would need to build, if there are no free utilities out there, would be a script that first outputs a list of folder contents that belong to the admin to a temp file.  Then, for each file run subinacl (or a similar executable) that sets the new owner.  If anyone has suggestions along those lines it would be appreciated.
0
 
HomerTNachoCheeseAuthor Commented:
I think my solution is the best solution because of price (free).  It has many manual steps, but I can live with that.  I am sure there are ways to throw this whole process into a batch file, eliminating the Excel steps and Notepad steps completely.  

Wilder - your solution appears it will work just as well, and probably be much more user-friendly at the same time, therefore, you get some points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.