Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell commands to copy file and folder permissions across volumes

Posted on 2011-02-16
4
Medium Priority
?
1,370 Views
Last Modified: 2012-05-11
Hey guys, I have a template folder (call it source) in a directory that I use to create new directories.  When my firm get's a new job a new project number is assigned and that number becomes a new folder a network share.  We use a template directory to create this share.  The template directory contains a standard set of folders with specific permissions.  Back in XP this was easy, I'd use SCopy.  Example. E:\templates> scopy source u:\proj11\12345 /s.  That command takes the "source" folder in the E:\templates directory and copies it to the U:\proj11 folder, names the new folder 12345 and retains the security from the source directory.  Well, I can't use SCopy anymore unless I use xp mode.  Besides I'd like to start using powershell more now anyway.  Can anyone give me a hand?  I'm a powershell n00b.  Thanks.
0
Comment
Question by:DKowalchik
  • 2
  • 2
4 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 34910490

Robocopy :) It'll copy the ACL and everything else you might want.

The rename part is trivial after that.

You could replicate that in PowerShell, but I'd debate the point when the existing tool is so good.

Chris
0
 

Author Comment

by:DKowalchik
ID: 34911329
Yes I know, this is easy with robocopy but was wondering what it would look like with Powershell.  I'm just getting into powershell for general admin tasks.  For me, the best way to learn something is to just it for everything I can.
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 34911433
Hmm I reckon copy the files, the pick up the SDDL form of the security descriptor and use that to transfer permissions.

e.g.
$SourceAcl = Get-Acl "C:\somefolder"
$Sddl = $SourceAcl.GetSecurityDescriptorSddlForm("All")

$DestinationAcl = Get-Acl "C:\SomeOtherFolder"
$DestinationAcl.SetSecurityDescriptorSddlForm($Sddl)
Set-Acl "C:\SomeOtherFolder" -AclObject $DestinationAcl

Open in new window

Makes sense?

Chris
0
 

Author Comment

by:DKowalchik
ID: 34911503
Thanks Chris I appreciate the example.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

927 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