Skip to content
Menu

Who Can Open This Folder - NTFS and Share Permissions

One row per permission entry on the folder and its subfolders to a depth you set, with share permissions and a flag for the entries that are almost always a mistake.

Who can open this folder - NTFS and share permissions is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Who can open this folder - NTFS and share permissions. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights
Read-onlyReads, changes nothing

What It Does

The script is read-only. It reads the NTFS access control list of FolderPath and of every subfolder down to Depth levels, and writes one row per permission entry. When the folder is shared, or sits inside a shared folder, it also writes one row per SMB share permission entry. It lists permission entries. It does not expand groups or calculate effective access for a user.

Each row says who (Identity), allow or deny (Type), what (Rights), whether the entry is inherited from the parent folder, and what it applies to. InheritanceBroken is true on a folder that no longer inherits from its parent, which means an administrator turned inheritance off there.

The Flag column is filled for the two entries that are almost always a mistake: Everyone or Authenticated Users with Allow and full control, on the folder or on the share. A subfolder with inheritance turned off is also flagged; the starting folder is not, because a share root is normally set up that way. Everyone and Authenticated Users are recognized by SID, so it works on any Windows language.

Junctions and symbolic links are not followed, so a loop cannot occur. The run stops after MaxFolders folders, 500 by default, and says so in a warning. Folders it cannot read are listed in warnings, not as errors. Share permissions are read for the starting folder only, not for shares set on subfolders below it. It needs administrator rights to read every permission list.

Before You Run It

  • Start with the share root or the folder you care about, and keep Depth small. The default of 2 is usually enough.
  • Raise MaxFolders only when you need it, because a big tree makes a big report.
  • Run it as an administrator or SYSTEM, or some permission lists cannot be read.
  • Run it again on a subfolder that is shared itself. Share permissions are read for the starting folder only.
  • Save it with ExportPath as a CSV to review in a spreadsheet.

Type and Risk

  • Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 1 minute for 500 folders.
  • Example answer: "Listed 38 permission entries on 12 folder(s) under D:\Shares\Finance (depth 2); 2 flagged"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • FolderPath: The folder to report on, e.g. D:\Shares\Finance. Required. (Named FolderPath, not Path: Windows already has an environment variable called Path, which the runtime would read instead.)
  • Depth: How many levels of subfolders to include below FolderPath. Whole number, 0 to 20. Default 2 (0 = only the folder itself).
  • MaxFolders: The most folders to read, so a huge tree cannot produce a huge report. Whole number, 1 to 100000. Default 500.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

get-folder-permissions.ps1 · 921 lines · 46.1 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.