Solved

Powershell commands to copy file and folder permissions across volumes

Posted on 2011-02-16
4
1,350 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
[X]
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
  • 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 500 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

What, When and Where - Security Threats from Q1

Join Corey Nachreiner, CTO, and Marc Laliberte, Information Security Threat Analyst, on July 26th as they explore their key findings from the first quarter of 2017.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

624 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