Retrieve ACL group with folder path

Anonymous
2024-03-28T13:35:59+00:00

I have to add specific ACL folder groups to target specific folders. As I am not able to create a script to do it automatically I thought to do it manually in two steps.

The groups list should be taken from a series of folders present in a source server and saved in a CSV file, according to the scheme below. I will use it later to add these groups to destination folders with another script.

I used the script below to recover the ACL groups but I don't know how to get an output as per picture below, where I can get the path of each folder and associated to it the members of each local groups.

Will be very helpful your help ;)

# Use PowerShell to get NTFS file permissions

$FolderPath = Get-ChildItem -Directory -Path "D:\VOLUME2" -Recurse -Force

$Output = @()

ForEach ($Folder in $FolderPath) {

*$Acl = Get-Acl -Path $Folder.FullName*  

*ForEach ($Access in $Acl.Access) {*  

$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}

$Output += New-Object -TypeName PSObject -Property $Properties

*}*  

}

$Output | Export-Csv -Path "D:\AgroupsVol2.csv" -NoTypeInformation

Windows Server Remote and virtual desktops PowerShell

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Anonymous
    2024-04-01T07:08:45+00:00

    Hi Marc_live,

    Not sure what kind of output you want. Are you trying to merge the accesses rules of one path to a single object?

    0 comments No comments
  2. Anonymous
    2024-04-01T08:43:34+00:00

    I have to recreate the same local ACL groups from one server to another server I have copied all folders (not ACL). They have the same name and drive letters.

    I need an output that I could use in a script to copy back all ACL groups to that I need the path of the folder and the ACL groups included.

    For Each volume a list of ACL groups associated with the folder.

    I wish to get something like that:

    D:\volume02

    D:\volume02\folder1, groupname11

    D:\volume02\folder1,groupname12

    D:\volume02\folder2,groupname21

    E:\volume02\folder3, groupname31

    E:\volume02\folder3,groupname32

    E:\volume02\folder3,groupname33

    E:\volume02\folder3,groupname34

    0 comments No comments
  3. Anonymous
    2024-04-02T07:57:12+00:00

    As per my understanding, you already have the folders and group names in the "Folder Name" and "Group/User" fields in your script. Do you just want to separate the results by the volume or insert the volume path?

    0 comments No comments
  4. Anonymous
    2024-04-02T12:43:01+00:00

    The script I showed at the beginning should collect all the necessary data.

    I would like to reorganize them in such a way that in the CSV file I have the path to the folder and next to it (separated by a comma) the ACL group contained in it.

    If there are multiple groups within the same folder it should be organized as the schema below :

    Path GroupName

    D:\volume02\folder1, localGroup1.1

    D:\volume02\folder1, localGroup1.2

    D:\volume02\folder1, localGroup1.3

    D:\volume02\folder2, localGroup2.1

    D:\volume02\folder2, localGroup2.2

    D:\volume02\folder3, localGroup3

    0 comments No comments
  5. Anonymous
    2024-04-03T07:16:34+00:00

    Sorry but I'm a little confused. It should be the names of the groups that have permissions on the folder in the column "Group/User" of the CSV file, say DomainName\group1, DomainName\group2, ComputerName\group3, so I think you've already got what you want in the CSV.

    "Folder Name","Group/User","Permissions",...

    "D:\volume02\folder1","DomainName\group1",....

    "D:\volume02\folder1","DomainName\group2",....

    "D:\volume02\folder2","ComputerName\group3",....

    Did I misunderstand what you meant by "ACL group"?

    0 comments No comments