troubleshooting Question

Permission on folders

Avatar of SAM IT
SAM IT asked on
PowershellScripting Languages
6 Comments1 Solution181 ViewsLast Modified:
Hello All,

Below script worked fine. Now i have added two more line to add the permission to folder. after folder created permission will be assigned only last line of permission I.E domain\userread123.  First 02 permission lines not assigning permission,

Thanks in advance

Set-Location "C:\Users\narasimha.s\Desktop\foldertest"
$Folders = Import-Csv C:\Users\Narasimha.s\Desktop\foldertest\project.csv
ForEach ($Folder in $Folders) {
    $newFolder = New-Item -name $Folder.Name -type directory
    $acl = Get-Acl $newFolder.FullName

    $ace = New-Object System.Security.AccessControl.FileSystemAccessRule('domain\usermodify', 'Modify,Synchronize', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
    $ace = New-Object System.Security.AccessControl.FileSystemAccessRule('domain\userread', 'Read,Synchronize', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
    $ace = New-Object System.Security.AccessControl.FileSystemAccessRule('domain\userread123', 'Read,Synchronize', 'ContainerInherit,ObjectInherit', 'None', 'Allow')

    Set-Acl $newFolder.FullName -AclObject $acl

Chris Dent
PowerShell Developer

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

Top Expert 2010

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 6 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 6 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