-1

May I please get your insight?

I have a user group in AD call Contract Admin. I like would this user group to be able to run a script that clones a template folder (retaining permissions) to a new folder and prompt for a new client name.

The folder structure would be as follows:

  • Clients
    • New Folder (template folder) (Permissions: Admins, Contract Admin, Financial Admin)
      • Statements Folder (Permissions: Financial Admin)

End result after script:

  • Clients
    • ABC Company (Permissions: Admins, Contract Admin, Financial Admin)
      • Statements Folder (Permissions: Financial Admin)

Above is an example of the folder structure where New Folder is the template folder which also has a folder inside of it as well. I'd like to have the folders cloned with permissions retained.

I hope this is clear, I apologize if it is not. Thank you so much for your help.

The code I currently have for copying the permissions are as folows:

robocopy /e /copy:DATS "X:\Template" "X:\New Folder Name"

attrib -h "Template"

This is what I have for cloning the folders but I am lost from here. Thank you

Solution: @echo off

set "src=C:\Users\XXX\Desktop\template folder"

set /p "dest=Name of Client?: "

robocopy /e /copy:DATS %src% %dest%


the source can simply be the folder/file name without the full path if both the script and the folder/file to be copied is in the same directory.

/copy: Specifies the file properties to be copied. The following are the valid values for this option:

  • D Data A Attributes
  • T Time stamps S NTFS access control list (ACL)
  • O Owner information
  • U Auditing information
  • The default value for
  • CopyFlags is DAT (data, attributes, and time stamps).
Rooney
  • 1
  • 1

1 Answers1

0

But this is not a script. It's a robocopy command.

There are many switches robocopy, see its help file for them.

Specifically the mirror (/MIR) a folder tree to a new location.

As for prompting users, there are a few ways to do this. The most direct is Read-Host cmdlet provides. You simply capture that in a variable and pass that as the folder.

$FolderPath = Read-Host 'Enter a folder path.'
postanote
  • 15,138
  • 2
  • 14
  • 25
  • Thank you so much, I will give this a shot. I am new to this scripting and I think i have confused myself with robocopy. – Rooney Nov 13 '18 at 18:33