Monday, October 30, 2017

Copy DACL from one folder to another

If you ever need to copy the access rights from one folder to another, this will help. This is also useful in cases where you need to duplicate the permissions from a folder to a recently re-created junction link.

Get-Acl -Path  SourceFolder | Set-Acl -Path  DestinationFolder

Here is an example:

Original State

  • There is a folder on the G: drive called 'Medicine'
  • There is a junction point on 'E:\Shared\Medicine' which points to the folder.
  • The permissions on the junction point are identical and complex

Some hero then deletes the junction point. This is then recreated thus:

mklink /j "E:\Shared\Medicine" "G:\Medicine"

We can then restore the junction link's missing DACL using PowerShell thus:

Get-Acl -Path "G:\Medicine" | Set-Acl -Path  "E:\Shared\Medicine"


Cheers!

No comments:

Post a Comment