Solved

Powershell commands to copy file and folder permissions across volumes

Posted on 2011-02-16
4
1,332 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 70

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 70

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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

Suggested Solutions

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now