POWERSHELL

Powershell – Set ACL for each folder with respective share foldels

This is working fine:

$csv = Import-Csv -Path “$env:userprofile\desktop\KDrivePath.csv”

ForEach ($item In $csv) {

    $acl = Get-Acl $item.Path

    $AddPerm = New-Object System.Security.AccessControl.FileSystemAccessRule($item.Name,”FullControl”,”ContainerInherit, ObjectInherit”, “None”,”Allow”)

    $acl.SetAccessRule($AddPerm)

    $acl | Set-Acl $item.Path

    Write-Host -ForegroundColor Green “Group $($item.Name) created!”

}

Leave a Reply

Your email address will not be published. Required fields are marked *