Need a script to create folders and permissions

Posted on 2012-08-20
Last Modified: 2012-08-28
Our Geography and Regional Planning department has several classes and sections. Previously, all of the students would have a general folder mapped for them via a GPO, and the professors would assign files, etc. The problem is that the students aren't following the procedures, and placing files everywhere, causing issues for both the professors and myself (finding lost files, etc).

So, I've created a new directory tree, and each student will have his/her own folder, with no access to any other folder other than the specific class folder.

Tree: Main shared folder -> General Student Folder -> Class Specific students folder -> Specific student folder

The idea script would take a student's name from a spreadsheet, create the folder, give the student specific modify rights, domain admins full control, professors read only rights.

I have seen other questions and answers for various scripts, but I'm not a programmer, and I don't know how to modify scripts to do what I want.

Thanks in advance.
Question by:wheelgunr
    LVL 12

    Accepted Solution

    Take a look at this:

    Also, here are several scripts for managing files and folders, but you may need to combine/rewrite a couple of them to get the exact result you are looking for:

    Author Comment

    Thanks for the links. I'll test them out before awarding and closing.

    Author Comment

    OK, I've run the script, and it does create the folders as needed. However, it doesn't create the security permission for the student. I need to have it create modify rights for that specifric student and his/her folder. Any ideas?

    Assisted Solution

    OK, I've modified a referred script that creates a user's folder based on their user ID and then gives them Modify rights:

    Const ForReading = 1

    strComputer = "SERVERNAME"
    Set objWMIService = GetObject ("winmgmts:\\" & strComputer _
        & "\root\cimv2:Win32_Process")

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set inputFile = objFSO.OpenTextFile("C:\Scripts\bio0204.txt", ForReading)

    Do Until inputFile.AtEndOfStream
        strFolders = inputFile.ReadAll

    arrFolders = Split(strFolders, vbCrLf)

    For i = 0 To UBound(arrFolders)
      createFolder = objWMIService.Create ("cmd.exe /c md c:\folder tree\" & arrFolders(i) & "", _
          Null, Null, intProcessID)
      assignACL = objWMIService.Create ("cmd.exe /c icacls.exe c:\folder tree\" & arrFolders(i) _
          & "" & " /Grant " & arrFolders(i) & ":(OI)(CI)M", Null, Null, intProcessID)

    To restrict access to specific classes,  I created a local group for each class at the root folder.

    What I need is a line of code that will remove that created local user group from the folders that will be created.

    Can anyone give me an idea as to that line of code?

    Author Closing Comment

    Still have an issue with removing a group that is inherited, but i'LL ask that in another queston

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now