增加权限- $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
复制代码
|