Maybe this is helpful:
Get-Acl \\server01\share\test1 | Set-Acl \\server02\share\test1
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Good Morning
I am new to powershell and I am struggling with the following scenario.
I have a folder that is set with specific security/permissions settings on 1 server and i need to copy that 1 folder to multiple servers with the same security/permission settings.
I know Robocopy could easily do this from 1 server to another server, but I need to copy it to multiple servers at once.
So I found the following site with information on creating a folder on multiple servers
https://powershell.org/forums/topic/creating-a-folder-remotely-using-variables/
that was helpful in creating the folder but I am unsure how to copy the the security/permissions?
any guidance on an approach would be helpful
Thank you
Maybe this is helpful:
Get-Acl \\server01\share\test1 | Set-Acl \\server02\share\test1
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten
Some thoughts. No matter what tool you use to mirror the folders between the multiple servers, there is going to be a time lag while the folders are created and the file data copied. So it all depends on how long your applications can "live with" partially synchronized folders. I think that it is going to be hard for you to recreate the efficiency that already exists in robocopy with your own script.
So the easiest thing to do would be to launch a robocopy process in parallel for each server using Powershell jobs.
https://devblogs.microsoft.com/scripting/parallel-processing-with-jobs-in-powershell/
Instead of, say, a bat file that robocopy's the files to server A, then server B, you would have multiple robocopy's that run at the same time. Now when they finish is going to be a function of network bandwidth and how much data you copy and how responsive the destination servers are.
You could take that one step further and robocopy each folder/file/subfolder 1 at a time with jobs. It all depends on your application requirements.
Hi,
According to the link you give, I assume that you create folders with a foreach loop. If you don't need to copy folders to multiple servers simultaneously, you can just invoke robocooy in the loop.
$servers | foreach{ robocopy $source $destination /E}
Best Regards,
Ian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Thank you for the responses, I am curious about answer 3.
$servers | foreach{ robocopy $source $destination /E}
if you use the server variable with the list of servers to copy the 1 folder with its permissions how would you identify the variable in the {expression}
$SRV=srv1,srv2,srv3
$SRV | foreach { robocopy d:\folder1 ??\d$ \copyall }
it is just a folder with 4 small files in it that is being copied to multiple systems but it is the permission settings on that folder that need to be copied.
What permissions are you applying? You should be using Active Directory groups and adding/removing users from/to the groups. Set the correct access on the folders, then you don't need to replicate the permissions on the files.
$Servers = @('srv1','srv2','srv3')
foreach ($Srv in $Servers) {
"Processing $Srv"
robocopy d:\folder1 \\$Srv\d$\folder1 /sec /e /l
}