繁体   English   中英

在许多文件夹中应用权限

[英]Applying permissions across many folders

我需要创建一个脚本,该脚本将对许多文件夹应用权限,具有不同的权限,具体取决于文件夹名称。 有一个根文件夹共享,其中是一个代表每个客户端的文件夹。 每个客户端文件夹内部都是一个部门文件夹。 我需要限制安全组对每个部门文件夹的访问权限,以便只有属于该部门的人员才能访问它们。

它看起来如下:

ROOT FOLDER SHARE  
|  
|-----CLIENT1 (everyone has access)  
|.......|------DEPARTMENT1 (only members of department1 have access)  
|.......|------DEPARTMENT2 (only members of department2 have access)  
|.......|------DEPARTMENT3 (only members of department3 have access)  
|  
|-----CLIENT2 (everyone has access)  
|.......|------DEPARTMENT1 (only members of department1 have access)  
|.......|------DEPARTMENT2 (only members of department2 have access)  
|.......|------DEPARTMENT3 (only members of department3 have access)  
|  
|-----CLIENT3 (everyone has access)  
........|------DEPARTMENT1 (only members of department1 have access)  
........|------DEPARTMENT2 (only members of department2 have access)  
........|------DEPARTMENT3 (only members of department3 have access)  

我不完全确定如何正确地解决这个问题。 请有人帮我指点正确的方向吗? 这是在运行Windows Server 2008 R2且具有活动目录设置的服务器上。

我目前看起来像这样(看起来它的工作原理):

$Path = Read-Host "What is the starting path?"
$DirectoryName = Read-Host "What is the name of the directory?"
$SecurityGroup = Read-Host "What is the name of the security group that will be given permissions on these directories?"
$ListOfDirectories = Get-ChildItem $Path -Recurse | Where-Object { $_.PSIsContainer } | Where-Object { $_.name -eq $DirectoryName } | foreach-object -process { $_.FullName }

foreach ($directory in $ListOfDirectories) {
    icacls.exe $directory /grant ""$SecurityGroup":M" /t
}

您可以使用Set-ACL命令通过PowerShell自动执行权限设置。

这是一个很好的文章overhere ,可以帮助你完成这个任务?

http://technet.microsoft.com/en-us/magazine/2008.02.powershell.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM