Site icon Actual Admins

Recovering NTFS inheritance

A little time ago, my (admin) user in Windows 10 was so badly damaged, that I had to re-create it.
While that was easily done, I found that the NTFS rights on my D: drive were a bit odd: Every folder had inherited an ACL right from D:\ for my old user (as an unrecognized S-xxx SID), but there was no entry on D:\ itself that referred to that user, so I could not remove any entry that supposedly was the origin for the inheritance.

In order to fix this, I decided to find out how to reset these NTFS permissions.
It turned out that I needed to reset the propagation of the inheritance. However, this wasn’t so straightforward, as (some of) the files and folders files were also still owned by my former user account, which I also wanted to repair.

The fix

In the end, I ended up using the below command as an Administrator to take ownership, remove any explicitly assigned ACLs and to enable inheritance propagation for all folders on the D: drive:

for /d %I in (d:\*.*) do (takeown /f "%~I" /a /r /d y&icacls "%~I" /reset /t /q /c&icacls "%~I" /inheritance:e /t /q /c)

Breakdown of the commands:

takeown /f "%~I" /a /r /d y

Take ownership of directory in variable “%~I”

icacls "%~I" /reset /t /q /c

Replaces explicit ACLs with default inherited ACLs for all matching folders.


icacls "%~I" /inheritance:e /t /q /c

Enable inheritance for all matching folders

Exit mobile version