Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Permission on folders

Avatar of SAM IT
SAM IT asked on
Scripting LanguagesPowershell
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

Avatar of Chris Dent
Chris DentFlag of United Kingdom of Great Britain and Northern Ireland imagePowerShell Developer
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers