我们正在研究一个新的许可概念。根据部门的不同,我们创建了不同的安全组。
例如:
Finance_List, Finance_Read, Finance_ReadWrite
Controlling_List, Controlling_Read, Controlling_ReadWrite
Planning_List, Planning_Read, Planning_ReadWrite现在,我正在寻找一个脚本来自动化在特定文件夹上设置GroupPermissions的过程。
示例:Folder Finance:禁用继承,然后设置新权限并将其替换为所有文件和子文件夹:组Finance_List (列表文件夹)、组Finance_Read (读)、组Finance_ReadWrite (修改)
CSV示例(Folderpath和每个文件夹的3 GroupPermissions ):
\\cifs\Finance;Finance_List;Finance_Read;Finance_ReadWrite我有300个安全组和100个文件夹。
任何帮助都将不胜感激。
谢谢!
发布于 2019-03-28 15:09:50
以下内容可以满足您的需要(确保CSV中的组与AD中的组名匹配,否则它将不能正常工作):
$Folders = Import-Csv "C:\Scripts\Folders.csv" -Delimiter ";" -Header "Path","List","Read","ReadWrite"
ForEach ($F in $Folders) {
$ACL = Get-Acl $F.Path
# Set the first parameter to $true to disable inheritance
# Set the second parameter to $false if you don't want to retain a copy the permissions to this folder.
# Set the second parameter to $true if you want to retain a copy of the inherited permissions.
$ACL.SetAccessRuleProtection($true, $true)
# 'ReadData' grants List Folder / Read Data
$List = New-object System.Security.AccessControl.FileSystemAccessRule($F.List,"ReadData","Allow")
$ACL.SetAccessRule($List)
# 'ReadAndExecute' grants Traverse Folder / Execute File
# 'Read' only grants List Folder / Read Data
$Read = New-object System.Security.AccessControl.FileSystemAccessRule($F.List,"ReadAndExecute","Allow")
$ACL.SetAccessRule($Read)
$ReadWrite = New-object System.Security.AccessControl.FileSystemAccessRule($F.ReadWrite,"Modify","Allow")
$ACL.SetAccessRule($ReadWrite)
$ACL | Set-Acl $F.Path
}这个网站有很好的例子,如何修改这个,如果需要,以及一个列表的各种访问权限和他们的Powershell等价物。如何使用PowerShell脚本管理文件系统ACL
https://serverfault.com/questions/960394
复制相似问题