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 79

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article runs through the process of deploying a single EXE application selectively to a group of user.
Last week, our Skyport webinar on “How to secure your Active Directory” ( provided 218 attendees with a step-by-step guide for identifying Acti…
The viewer will learn how to dynamically set the form action using jQuery.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

17 Experts available now in Live!

Get 1:1 Help Now