Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Creating an array of directories

$
0
0

I need to be able to adjust the permissions on a directory. Because the directory tree is quite extensive, I plan on only inspecting and changing the first three layers of a directory. So, a directory will be copied via Robocop (with /E /SEC /MIR switches) and groups will be added to the ACL for the first three layers.

Now, the first step is to create an array that lists the directories in question. I imagine using something along the lines of Get-Childitem -Path <path to top level directory> -Recourse -Force|where-object {$_.psIsContainer} but I need to account for the possibility that the top level directory will have no child folders or that they will only be one layer deep. I also need to go at least three layers should it goes that deep. I will not look past three layers as I imaging the program will take quite some time to run.

Once I have a list of the directories, I want the array to have two more columns- one with the IdentityReference and the other with FileSystemRights. Both of these properties come from Get-ACL <path from the first column>|select -expand access. Once I get it populated, I will look for a certain string (those IdentityReference =Domain B) and change it to a IdentityReference for a different group in Domain B. I will not be replacing but adding. Anyway, I will then send this over to set-ACL to add these new groups.

I am not looking for the program but a good way of stepping through the directories-any ideas would be appreciated.


Viewing all articles
Browse latest Browse all 13067

Latest Images

Trending Articles



Latest Images