标题: [技术讨论] PowerShell修改ACL设置文件安全权限 [打印本页]
作者: DAIC 时间: 2013-11-4 15:28 标题: PowerShell修改ACL设置文件安全权限
增加权限- $filePath = "D:\Test\a.txt"
- $account = "Everyone"
- $FileSystemRights = "FullControl"
- $objType = [System.Security.AccessControl.AccessControlType]::Allow
-
- $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($account,$FileSystemRights,$objType)
- $acl = Get-Acl $filePath
- $acl.SetAccessRule($accessRule)
-
- Set-Acl -Path $filePath -AclObject $acl
复制代码
删除权限- $filePath = "D:\Test\a.txt"
- $account = "Everyone"
- $FileSystemRights = "FullControl"
- $objType = [System.Security.AccessControl.AccessControlType]::Allow
-
- $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($account,$FileSystemRights,$objType)
- $acl = Get-Acl $filePath
- $acl.RemoveAccessRule($accessRule)
-
- Set-Acl -Path $filePath -AclObject $acl
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |