Avatar of SAM IT
SAM IT
 asked on

Permission on folders

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')
    $acl.AddAccessRule($ace)

    Set-Acl $newFolder.FullName -AclObject $acl

}

Open in new window

PowershellScripting Languages

Avatar of undefined
Last Comment
SAM IT

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Dent

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SAM IT

ASKER
WOrks perfectly.

Instated if Read I have mentioned Full getting error

What would be the syntax for Full Permission
Chris Dent

FullControl :)
SAM IT

ASKER
Fullcontrol works fine,

Before posting I tried Full control not worked.

Thank you chris
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SAM IT

ASKER
Fullcontrol works fine,

Before posting I tried Full control not worked.

Thank you chris
SAM IT

ASKER
hello Chris

I want to disable in heritance on the folder level

want to know command line to disable inheritance