We help IT Professionals succeed at work.

How do I write a script to create a user folder and set permissions at the same time?

My goal is to create a user folder, and then assign only the domain admins and the user the ability to open the folder (write, read, edit, etc.).

So far I have:

mkdir  \\servername\subfolder\reports\TOMJONES
echo y| Xcacls.vbs \\servername\subfolder\reports\TOMJONES /I REMOVE
echo y| cacls \\servername\subfolder\reports\TOMJONES /E /G "Domain Admins":F "Administrators":F TOMJONES:F

The folder is created, but the permissions are not being set.  Please help!  Thanks
Watch Question

erobbySenior Systems Engineer

md \\servername\subfolder\reports\TOMJONES
icacls \\servername\subfolder\reports\TOMJONES /grant "Administrators":(F)
icacls \\servername\subfolder\reports\TOMJONES /grant "Domain Admins":(F)
icacls \\servername\subfolder\reports\TOMJONES /grant "TomJones":(F)
Senior Systems Engineer
Sorry about the first one.  But you will need to specify the location of the folder each time you run it.

md \\servername\subfolder\reports\TOMJONES
icacls \\servername\subfolder\reports\TOMJONES /grant "DOMAIN\Administrators":(F)
icacls \\servername\subfolder\reports\TOMJONES /grant "DOMAIN\Domain Admins":(F)
icacls \\servername\subfolder\reports\TOMJONES /grant "DOMAIN\TomJones":(F)


Thank you!
erobbySenior Systems Engineer

You are more then Welcome and thanks for the points