Solved

Powershell commands to copy file and folder permissions across volumes

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This article will help you understand what HashTables are and how to use them in PowerShell.
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 go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

707 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

15 Experts available now in Live!

Get 1:1 Help Now