Jump to content

Recommended Posts

Posted

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!

Posted

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

 

 

'Global variables
Dim Container
Din objShell

'Initialize global variables
Set objShell = CreateObject("Wscript.Shell")
Set Container=GetObject("LDAP:///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

  • Thanks 1
Posted

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.

  • Thanks 1
Posted
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 :D That's worked a treat, saundersmatt, your way just went straight over my head....but it looks good! :p

Posted

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 :p

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...