Powershell script - set folder permissions
Posted on 2011-09-02
I have a Windows 2008 file server. I have the following share
D:\Folder1 > this folder is shared to domain users with "list folder contents only"
Reason: Directory structure inside Folder1 is company standard.
Permissions to be set on each subfolder: disallow inheritable permissions from parent. Then set the modidy permission for each folder.
So i found this powershell script to do this. However i cant seem to understand what could be inside c:\folders.txt. i am thinking it could be some kind of permission statement
Also can you explain the foreach loop?
I am learning powershell now and i have had to refresh my mind scripting which i havent done in a long time.
New-Item ('c:\Folder1\UserFolder' + $i) -type directory
$Users = Get-Content 'C:\Folders.txt'
# grabs the ACL from the model folder created to duplicate acl to folders 1-200
$acl = Get-Acl ('C:\Folder1\Model')
ForEach ($user in $users)
$newPath = Join-Path "C:\Folder1\" -childpath $user
$acl | Set-Acl $newPath