Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

10
Exporting all permissions of all fileshares to CSV. Hit the row limit of excel. Ways around this? Other methods of obtaining the data?
Post Body

Hi All

A customer of ours has requested an export of all the file shares on all thier servers along with the permissions of all the file shares.

They are planning to move to cloud storage at some stage and want an export of this data from thier servers.

I made a script that takes in some UNC Paths and exports the folder name, and permissions of said folders and exports them to a CSV

Here is the script im using

        $ShareNames = @(
            "\\?\UNC\fs-hd-01\Common",
            "\\?\UNC\fs-hd-01\Information Services",
            "\\?\UNC\fs-hd-01\Lean Supply Chain",
            "\\?\UNC\fs-hd-01\Logon Audit",
            "\\?\UNC\fs-hd-01\Machine Learning",
            "\\?\UNC\fs-hd-01\Operational",
            "\\?\UNC\fs-hd-01\SD",
            "\\?\UNC\fs-hd-01\Search DB",
            "\\?\UNC\fs-hd-01\Software Library",
            "\\?\UNC\fs-hd-01\Supplier Sales Reports 18.1.2",
            "\\?\UNC\fs-hd-01\TenderMax",
            "\\?\UNC\fs-hd-01\Scans",
            "\\?\UNC\fs-hd-01\UHYHN"
            # Add more share names as needed
        )

        $Results = foreach ($ShareName in $ShareNames) {
            $AllFolders = Get-ChildItem -LiteralPath $ShareName -Directory -Force -Recurse

            foreach ($Folder in $AllFolders) {
                $Acl = Get-Acl -LiteralPath $Folder.PSPath

                    foreach ($Access in $Acl.Access) {
                        if ($Access.IsInherited -eq $false -and
                                $Access.IdentityReference.Value -notin "BUILTIN\Administrators", "CREATOR OWNER", "NT AUTHORITY\SYSTEM", "BUILTIN\users") {
                            [PSCustomObject]@{
                                'FolderName'  = $Folder.FullName
                                'AD Group'    = $Access.IdentityReference
                                'Permissions' = $Access.FileSystemRights
                            }
                        }
                    }
                }
            }

$ExportPath = "C:\temp\permissions.csv"
$Results | Export-Csv -Path $ExportPath -NoTypeInformation -Force

The server im running this on has a 2tb drive with hundreds of thousands of folders. I let the script run overnight and got an excel spreadsheet that error'ed out with a row limit

Does anyone know of a more efficient way of doing this? How can I make my life easier? I have 50 servers that i need to check through

Would it be better to run this on the servers directly using the exact directory rather than the UNC Paths?

Thanks

Author
Account Strength
100%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
45,934
Link Karma
35,950
Comment Karma
8,954
Profile updated: 6 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago