【问题标题】:Applying permissions across many folders跨多个文件夹应用权限
【发布时间】:2023-04-06 05:22:02
【问题描述】:

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

如下所示:

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
}

【问题讨论】:

  • 到目前为止你尝试过什么?你到底在哪里卡住了?向我们展示您已经一些努力尝试将工作脚本放在一起。

标签: powershell windows-server icacls


【解决方案1】:

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

有一篇很好的文章overhere可以帮助你完成这个任务...

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    • 1970-01-01
    • 2011-08-12
    相关资源
    最近更新 更多