+ Post New Thread
Results 1 to 6 of 6
Coding Thread, setACL help please quick aggh :p in Coding and Web Development; Had a fairly stupid accident and i need some urgent help... This folder "H:\Home10" is home to 239 student folders, ...
  1. #1
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,659
    Thank Post
    383
    Thanked 273 Times in 225 Posts
    Rep Power
    103

    setACL help please quick aggh :p

    Had a fairly stupid accident and i need some urgent help...

    This folder "H:\Home\2010" is home to 239 student folders, the permissions have become fubared on all 239 folders...

    I need to run a script against these to set specific permissions, the quickest method of setting these permissions would probably be to apply the student permissions using the folder name....so first off i need to know how i can tell a script to use the folder name as a username to add to the permissions list

    Secondly i need to add domain admins and it teachers - this bit i can do

    Does anyone know how to use the folder name? Hard to explain but i know it's possible!

  2. #2

    Join Date
    Jul 2005
    Location
    Rugby
    Posts
    432
    Thank Post
    17
    Thanked 66 Times in 61 Posts
    Rep Power
    36
    Having done this in the past I wrote a script that will enumerate all users in an OU and reset the permissions on their home directory (from AD) to full control for their username(from ad). Will take a little modifying to set the additional permissions you require.

    Matt


    Code:
    'Global variables
    Dim Container
    Din objShell
    
    'Initialize global variables
    Set objShell = CreateObject("Wscript.Shell")
    Set Container=GetObject("LDAP://<AnyDC>/OU=The,OU=OU,OU=Path,DC=domain,DC=domain")
    
    'Enumerate Container
    EnumerateUsers Container
    
    'Clean up
    Set Container = Nothing
    
    'Say Finished when your done
    WScript.Echo "Finished"
    WScript.Quit(0)
    
    'List all Users
    Sub EnumerateUsers(Cont)
    Dim User
    'Dim folder
    
    'Go through all Users and select them
    For Each User In Cont
    Select Case LCase(User.Class)
    
    'If you find Users
    Case "user"
    
    ExecCommand= "cacls " & "" & chr(34) & User.homeDirectory & chr(34) &"" & " /t /e /c /g "   & "" & User.userPrincipalName & "" & ":F"
    Wscript.Echo "Outputting for user: " &  User.name
    Wscript.Echo ExecCommand
    set oCommand = objShell.Exec(ExecCommand)
    wscript.echo oCommand.stdout.readall
    WScript.Echo "***** END USER********"
    
    Case "organizationalunit" , "container"
      EnumerateUsers User
    
    End Select
    Next
    End Sub

  3. Thanks to saundersmatt from:

    mrbios (4th October 2011)

  4. #3


    Join Date
    Jul 2007
    Location
    Rural heck
    Posts
    2,662
    Thank Post
    120
    Thanked 433 Times in 352 Posts
    Rep Power
    127
    dir /b > textfile.txt

    Copy and paste into excel,

    Use the 'CONCATENATE' function to built the correct command in another column.

    Copy and paste the new column into notepad and save as a bat file.

  5. Thanks to K.C.Leblanc from:

    mrbios (4th October 2011)

  6. #4
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,659
    Thank Post
    383
    Thanked 273 Times in 225 Posts
    Rep Power
    103
    Quote Originally Posted by K.C.Leblanc View Post
    dir /b > textfile.txt

    Copy and paste into excel,

    Use the 'CONCATENATE' function to built the correct command in another column.

    Copy and paste the new column into notepad and save as a bat file.
    Got to admit, i didn't try this last night as i was being lazy/thinking it would take more doing than it did...........just done this now and it's actually easier than i thought it would be. Cheers That's worked a treat, saundersmatt, your way just went straight over my head....but it looks good!

  7. #5
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,659
    Thank Post
    383
    Thanked 273 Times in 225 Posts
    Rep Power
    103
    I have another query....what's the command to remove inherited permissions from a folder and just leave the non-inherited ones?

    I can see the command to do the reverse but not that

  8. #6

    Join Date
    Jul 2005
    Location
    Rugby
    Posts
    432
    Thank Post
    17
    Thanked 66 Times in 61 Posts
    Rep Power
    36
    I'd use icacls /inheritance:r

    Matt



SHARE:
+ Post New Thread

Similar Threads

  1. Default gateway settings etc. help please.
    By tickmike in forum Wireless Networks
    Replies: 21
    Last Post: 17th September 2006, 04:44 PM
  2. Ghost 8 Ghostwalker Not Working..Urgent Help please.
    By tickmike in forum How do you do....it?
    Replies: 5
    Last Post: 4th September 2006, 04:34 PM
  3. Replies: 5
    Last Post: 4th July 2006, 06:39 PM
  4. questionaire linked to database help please!!!!!!!!!!!!!!!!!
    By suesmate in forum Educational Software
    Replies: 8
    Last Post: 3rd May 2006, 07:07 PM
  5. E Learning Credits - Help Please
    By MuppetQueen in forum Budgets and Expenditure
    Replies: 4
    Last Post: 12th December 2005, 04:10 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •