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 80

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSV file copy field 1 to field 2 2 35
Unable to hit site 2 23
debug scriptblock parameters in powershell script 2 20
powershell event viewer 1 17
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
The viewer will learn how to count occurrences of each item in an array.

685 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