设想情况:
我们的公司HR共享文件夹有以下目录方案:
Jane_Doe
John_Doe
所有100名员工都有15个文件夹。每个文件夹的文件夹权限如下:
01_Agreements :对人力资源和薪资的完全控制
02_Wages :对人力资源和薪资的完全控制
03_Discipline :对人力资源的完全控制(不能访问薪资)
像这样手动调整文件夹权限是管理上的噩梦。理想情况下,我们将根文件夹拆分为"HR和工资访问“文件夹和"HR只访问”文件夹。不幸的是,这是不可能的。
我要寻找的是一种快速将适当权限应用于每个目录中的每个文件夹的方法。
有什么办法可以做到吗?我正在检查一个用于调整一个文件夹的权限的基本脚本,它似乎很有效,但我无法确定如何以这种格式使用多个用户名/文件夹:
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
Write-host "My directory is $dir"
$Acl = Get-Acl "$dir\01_TestFolder"
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("bray.g", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$Acl.SetAccessRule($Ar)
Set-Acl "$dir\01_TestFolder" $Acl发布于 2017-12-20 17:29:24
最后生成一个更新文件夹权限的批处理文件。使用此方法并复制所有必需的文件夹。
REM Used to update/add folder permissions to the Shared HR folder. Adjust as necessary
REM - DR 12/11/2017
icacls "01_Agreements" /t /grant USER.1:(OI)(CI)F
icacls "01_Agreements" /t /grant USER.2:(OI)(CI)F
icacls "01_Agreements" /t /grant UsER.3:(OI)(CI)F
REM Remove "REM" from the next line to delete the file after running
REM del "permissions.bat"https://stackoverflow.com/questions/47700009
复制相似问题