GPO to change all files/folders ownership only
-
Wednesday, January 30, 2013 4:07 PM
We had an issue where an admin to fix an issue reset the owner on most of our Windows 7 PC from "TrustedInstaller" to Administrators (replace on all files and subfolders). This has caused issues. I'd like to set this back via GPO or some other method.
I have a GPO that is supposed to reset the owner for this but at the same time it will set the security. I'd like to reset JUST the ownership on all the files/folders on a Windows 7 PC and not change any other security settings/ACLs...
How can I do this?
it seems they are tied. I'm hesitant to remove the security permission in that it will do the same on the PC's and break everything.
Help...
RS
All Replies
-
Wednesday, January 30, 2013 5:09 PM
Try this - and enjoy :-)
icacls "%windir%\winsxs\Catalogs" /setowner "NT Service\TrustedInstaller" /T /C
- Marked As Answer by Andy QiMicrosoft Contingent Staff, Moderator Wednesday, February 06, 2013 6:25 AM
-
Wednesday, January 30, 2013 8:37 PM
You need a startup script that executes with SYSTEM permissions. Thisscript has to launch the appropriate commands.One command is icacls - as Thorsten already mentioned. Another commandis takeown (also part of windows). And of course, there's Helge Klein'spopular "setacl" command line tool...regards, Martin
NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!- Marked As Answer by Andy QiMicrosoft Contingent Staff, Moderator Wednesday, February 06, 2013 6:25 AM
-
Thursday, January 31, 2013 8:55 AMModerator
Hi,
I agree Torsten, he has provided the right suggestions to your question. As he mentioned, we could use Icacls command to change the owner of a file or a folder. For details about Icacls, please refer to the following article.
Icacls
http://technet.microsoft.com/en-us/library/cc753525(v=ws.10).aspx
In addition, we could also deploy a script via Group Policy to change the file ownership. Here are some script samples as reference, hope this helps.
How Can I Determine the Owner of a File?
How Can I Take Ownership of a File or Folder By Using a Script?
If you have some trouble modifying the script, I suggest we could ask in the script forum.
The Official Scripting Guys Forum!
http://social.technet.microsoft.com/Forums/en-US/ITCG/threads
Best Regards,
Andy Qi
If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.
Andy Qi
TechNet Community Support- Marked As Answer by Andy QiMicrosoft Contingent Staff, Moderator Wednesday, February 06, 2013 6:25 AM
-
Thursday, January 31, 2013 1:40 PM
Thanks for the suggestions.
I did ask the scripting guys and the response was to create a GPO...
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/fde82d8b-d33c-4697-8d03-f7516b898a26/
But I see that Torsten's command is a bit different then mine...
icacls c:\ /setowner "nt service\trustedinstaller" /t /c /l /q
Another question...
If the original take ownership was done as an Administrator and not system I'm thinking I can change what was changed that time just by running the command as administrator again... My thinking is that anything that was denied the first time around would be denied this time as well and I won't change anything this time that wasn't changed with the original error.
Would you agree?
-
Thursday, January 31, 2013 3:46 PM
The /l is for symbolic links. The /q will surpress messages. I don't recommend these both switches.
Your second question:
That should cause no troubles with this command. If you run in troubles with it than run the command a second time and it should be done. Keep in mind that you need to run this command with admin privileges.
-
Thursday, January 31, 2013 4:16 PM> icacls c:\ /setowner "nt service\trustedinstaller" /t /c /l /qOn the second reading: I didn't test, but I doubt this command will workif you do NOT already have full access to a file (so you can set anowner). In that case, you need to takeown first...
NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!


