troubleshooting Question

Powershell Script request: remove folder security inheritance

Avatar of Ben Hart
Ben HartFlag for United States of America asked on
Scripting LanguagesWindows Server 2008Powershell
3 Comments1 Solution616 ViewsLast Modified:
"users" folder on specific server share.  Random number of folders setup incorrectly up to two years ago, searching row by row too time consuming for 500+ users so I'm looking for a script that still stop inheritance and manually change a couple of the security entries.

Namely removing inheritance, adding the folders owner with full control (if they do not already exist), also removing "Authenticated Users" and/or "jak-2k3-mss/users" if they exist.

So folder named "Bsmith" current Security tab:

Administrators - Full
Authenticate Users - Modify
Domain Admins - Full
Backup Exec - Full
System - Full
Users - Modify

Changed to:

Administrator - Full
Domain Admins - Full
Backup Exec - Full
System - Full
Bsmith - Full (bsmith is also the folder name per login script if that helps)

The login script right now checks for the existence of a folder that matches the username, if none it creates one.

The folder creation part of the login script:
Sub CheckForUserFolder(UserName)
On Error Resume Next
Dim ObjFSO
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
	If Not(ObjFSO.FolderExists("\\jak-2k3-mss\users\" & UserName)) Then 
		Set newfolder = ObjFSO.CreateFolder("\\jak-2k3-mss\Users\" & UserName)
	End If
End Sub

Open in new window


I include that in case I've got something wrong or if there's a variable I can add that will add the user with full control during creation time.
ASKER CERTIFIED SOLUTION
soostibi

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros