Clone NTFS Permissions

NTFS access permissions can be complex and tricky. To quickly assign NTFS permissions to a new folder, you can simply clone permissions from another folder that you know has the correct permissions applied.

md $home\sample

# manually assign correct permissions to folder "sample"
$sddl = (Get-Acl $home\sample).Sddl
md $home\newfolder
$sd = Get-Acl $home\newfolder
$sd.SetSecurityDescriptorSddlForm($sddl)
$sd.Sddl
Set-Acl $home\newfolder $sd

Unfortunately, setting ACLs this way always requires administrator privileges.


Posted Mar 24 2009, 08:00 AM by ps1

Comments

Carpe Diem: Flaphead.com wrote Clone NTFS Permissions
on 04-21-2009 1:29 PM

I have done this before when moving log file locations in Exchange and it’s well cool and make life very

mindmesh wrote re: Clone NTFS Permissions
on 04-30-2009 10:47 PM

In this example the two directories you created already have the same permissions because they were created in the same folder. I get the following error when i attempt too run this script against two existing folders with different permissions

Set-Acl : Attempted to perform an unauthorized operation.

At line:1 char:8

+ set-acl  <<<< $home\Test $sd

Aleksandar wrote re: Clone NTFS Permissions
on 05-01-2009 6:51 AM

That example works and the folders don't have the same permissions, because you will manually assign correct permissions to sample folder before you apply them to target folder. Code could be a little simpler using pipeline:

md $home\sample

# manually assign correct permissions to folder "sample"

md $home\newfolder

Get-Acl $home\sample | Set-Acl -path $home\newfolder

mindmesh wrote re: Clone NTFS Permissions
on 05-01-2009 9:09 AM

It appears to work in the office, but on the home system the code failed with the above error. I had permissions to both folders. I'm and admin on the system and I was the owner. The folders were on two different drives, but that shouldn't matter as the code you just supplied worked across the network.

Thank you for the help.

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.