Solved

Powershell commands to copy file and folder permissions across volumes

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
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.

685 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