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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 81

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

710 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