locked
Recursive script to add Full control for Administrators? RRS feed

  • Question

  • Does anyone have a script that I can modify to change all the file and folder permissions on my primary (boot) storage device to give Administrator's Full control? It seems I cannot do it en masse but need to do a recursive loop through all files/folders, and for each, save the owner, take ownership, add Administrators:F, then finally restore original ownership. If there is an error, it should keep going.

    I found "GET-ACL $CurrentFile | Select Owner" but I haven't seen how to extract just the owner from the several lines of text it puts out. It seems this script should only take a half dozen lines, however my inexperience makes me worry there will be problems that I cannot anticipate. For example I thought I had once found that the system sometimes gets angry if it doesn't find the expected owner for a file or folder (e.g., TrustedInstaller), but I've read many posts that imply this should not be the case.

    Saturday, August 10, 2019 9:24 PM

Answers

  • GET-ACL $CurrentFile | Select -expand Owner


    Keith

    • Marked as answer by GregJ7 Friday, September 6, 2019 12:33 PM
    Saturday, August 10, 2019 11:28 PM

All replies

  • GET-ACL $CurrentFile | Select -expand Owner


    Keith

    • Marked as answer by GregJ7 Friday, September 6, 2019 12:33 PM
    Saturday, August 10, 2019 11:28 PM
  • You don't want to do this. Many folders and files are specifically protected by Windows. To alter all files and folders would effectively destroy Windows security and, possibly, make Widows unmaintainable.

    Also this forum is not for script requests. See the first post at the top of this forum for guidance.

    Forum Posting Guidelines Alert me


    \_(ツ)_/

    Saturday, August 10, 2019 11:29 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Friday, September 6, 2019 12:30 PM