PowerShell Set-Acl recursively

Posted on 2014-03-05
Last Modified: 2014-03-06

I have the below script, works fine but when setting the ACL it only set's the ACL on the root folder and doesn't propagate down. How can I get it to set the ACL to all files and folders?

1) imports folder names from folderlist.txt
2) gets fqdn and serve rip info from input.csv
3) copies folders from 1 server location to another server location
4) copies acl per folder from location 1 and set's the acl per folder on location 2

This works great, but I need the permissions to propagate down on location 2.

Thank you.

gc folderlist.txt | % {
$user = "$_"
Import-Csv "C:\TEMP\Favorites\input.csv" | ForEach {
If ($_.FQDN -eq $env:USERDNSDOMAIN) { $file_server = $_.'Server IP' } 
if (Test-Path -Path "\\$file_server\profiles$\$user\Favorites")
copy-item -path  \\$file_server\profiles$\$user\Favorites -destination \\$file_server\userhome$\$user\Favorites -recurse -force 
copy-item -path  "\\$file_server\profiles$\$user\Application Data\Microsoft\Signatures" -destination \\$file_server\userhome$\$user\AppData\Roaming\Microsoft\Signatures\ -recurse -force -ErrorAction SilentlyContinue
Get-Acl -path \\$file_server\profiles$\$user\Favorites\ | Set-ACL -path \\$file_server\userhome$\$user\Favorites\
Get-Acl -path  "\\$file_server\profiles$\$user\Application Data\Microsoft\Signatures\" | Set-Acl \\$file_server\userhome$\$user\AppData\
remove-item -path  \\$file_server\profiles$\$user -recurse -force

Open in new window

Question by:levertm
LVL 78

Accepted Solution

David Johnson, CD, MVP earned 500 total points
ID: 39908791
$NewAcl = Get-Acl File0.txt
Get-ChildItem c:\temp -Recurse  -Force | Set-Acl -AclObject $NewAcl

Open in new window

from powershell help set-acl -examples

Author Comment

ID: 39909325
Hi David,

I tried your suggestion, it works. Thank you.

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this previous article (, we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now