change permissions to folder root and child files and folders

Welcome Forums General PowerShell Q&A change permissions to folder root and child files and folders

Viewing 6 reply threads
  • Author
    Posts
    • #254948
      Participant
      Topics: 5
      Replies: 9
      Points: 67
      Rank: Member

      Hello.

       

      Thanks in advance for assistance with this.

       

      With the below script I am trying to ammend folder permissions for folders, child folders and files from within that folder also.  I can only seem to ge 5 child folders depp though.  I would like to recurivley run this to ensure all child folder permissions are ammended.

       

      Code:

      • This topic was modified 4 months, 1 week ago by jimleslie7778.
      • This topic was modified 4 months, 1 week ago by kvprasoon.
    • #255086
      Senior Moderator
      Topics: 9
      Replies: 1445
      Points: 5,410
      Helping Hand
      Rank: Community MVP

      What you would probably need is to use -Recurse switch parameter of Get-ChildItem cmdlet then use ForEach-Object cmdlet to iterate through each folder item coming through.
      If you have not used these options, I suggest you to read documentation using Get-Help ForEach-Object -Full cmdlet.

    • #262463
      Participant
      Topics: 5
      Replies: 9
      Points: 67
      Rank: Member

      thanks for the help, i have added the -recurse itch but this still seems to fail for child folders, whilst sucessfully ammending the first folder and files within there, any ideas?

    • #262586
      Participant
      Topics: 9
      Replies: 702
      Points: 2,819
      Helping Hand
      Rank: Community Hero

      I find the -Recurse parameter of Get-ChildItem to be a little slow. I also like recursive functions. This function will go through and set each folder and file recursively. You simply pass it the root folder to start with and the account. I’ve also prepared it to take AccessRights and AppliesTo as a parameter with the default being what you were trying to achieve. If you want to see the items as they are being set then add -Verbose. I turned verbose off on the NTFSAccess command as it was very, very noisy.

    • #262691
      Participant
      Topics: 5
      Replies: 9
      Points: 67
      Rank: Member

      would this have the ability to apply those permissions without modifying the folder owners? as these are homefolders each folder owner needs to be the individual users

    • #262718
      Participant
      Topics: 9
      Replies: 702
      Points: 2,819
      Helping Hand
      Rank: Community Hero

      It’s your command… you tell me. I only used the command you were already using. Plus, you could simply test it and see..

    • #263214
      Participant
      Topics: 5
      Replies: 9
      Points: 67
      Rank: Member

      Fair point, I test and no it doesnt change the folder owners, massive bonus there!!

      one further question, is there a way of pulling several (possibly hundreds) of folders from a csv or text file then applying this to them?

Viewing 6 reply threads
  • The topic ‘change permissions to folder root and child files and folders’ is closed to new replies.