Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Moving File Structure Skeleton and Copying ACL

$
0
0

I'm working on moving a set of folders from one server location to another. Everything seems to work fine except the last for-each isn't processing. I'm not receiving any error. Files copy okay but the permissions do not. 

$destination ='\\someserver\legal\test1'

$source = ''\\someserver\legal\test2'


Get-ChildItem -Path $source -recurse | Where-Object {$_.PSIScONTAINER -EQ $TRUE} |  
ForEach-Object { $_.FullName -replace [regex]::Escape($source), $destination } | 
ForEach-Object { $null = New-Item -ItemType Container -Path $_ }  
Get-ChildItem -Path $source -recurse | Where-Object {$_.PSIScONTAINER -EQ $TRUE} |
ForEach-Object {


   Get-Acl -Path $_.FullName | Set-Acl -Path "$destination\$(Split-Path -Path $_.FullName -Leaf)"
   write-host "copying ACL for $_"
}

Edit: Found and corrected part of my mistake. With the code above everything is working except for changing the ACL on the child objects. 



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>