Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

script for seeting and removing permissions

$
0
0

Hi all,

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


$pfad = "c:\data\groups"

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


Viewing all articles
Browse latest Browse all 6937

Trending Articles