script for seeting and removing permissions

by Sep 3, 2015

Hi all,

So far I got this script for creating folders and setting up acls on the folders.

$pfad = "c:datagroups"

Set-Location "c:"


$Folders = Import-Csv "c:test.csv"


ForEach ($Folder in $Folders)


 if (Test-Path $Folder.Name) {
         Write-Host "Folder: $Folder.Name Already Exists"
 } else {
         Write-Host "Creating $Folder.Name"
         New-Item $Folder.Name -type directory

$Dir = $Folder.Name
$User = $Folder.User
$Perm = $Folder.Perm
$Rule = $Folder.Rule


$ACL = Get-Acl "$Pfad$Dir"

$ACL.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("$User", "$Perm", "ContainerInherit,ObjectInherit", "None", "$Rule")))

Set-Acl "$pfad$dir" $Acl



When users are removed from the csv file how can I also remove there specific permissions from the folders?

thanks already guys