Copy NTFS permissions between folders.
#
# Transfer DACL, SACL and object owner using PowerShell:
# https://confidentialfiles.wordpress.com/2014/03/13/copying-ntfs-permissions-between-folders/
Get-Acl -Path 'C:\path\to\source' | Set-Acl -Path 'C:\path\to\destination'
#
# Using icalcs (https://serverfault.com/a/404038)
#
# The '/t' switch allows it to get sub-folder permissions too. The '/c' switch
# allows it to continue even if errors are encountered (although errors will
# still be displayed).
#
icacls D:\source /save perms.txt /t /c
icacls D:\destination /restore perms.txt
#
# PowerShell 3.0 (Remove the `-WhatIf` when you are sure it is targeting the right folders):
# http://stackoverflow.com/a/28446513
$savedACL = get-acl "C:\script\banana"
Get-ChildItem "C:\script\architecture" -Directory -Recurse | ForEach-Object {
$_ | Set-Acl -AclObject $savedACL -WhatIf
}
#
# PowerShell 2.0 (Remove the `-WhatIf` when you are sure it is targeting the right folders):
# http://stackoverflow.com/a/28446513
$savedACL = get-acl "C:\script\banana"
Get-ChildItem "C:\script\architecture" -Recurse | Where-Object{$_.PSIsContainer} | ForEach-Object {
$_ | Set-Acl -AclObject $savedACL -WhatIf
}