返回列表 发帖

[技术讨论] 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 $aclCOPY
删除权限
$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 $aclCOPY

返回列表