File: check_file_access_rules.ps1

package info (click to toggle)
ruby-specinfra 2.94.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,464 kB
  • sloc: ruby: 10,562; makefile: 4
file content (8 lines) | stat: -rw-r--r-- 366 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
function CheckFileAccessRules
{
  param($path, $identity, $rules)
  
  $accessRules = @((Get-Acl $path).access | Where-Object {$_.AccessControlType -eq 'Allow' -and $_.IdentityReference -eq $identity })
  $match = @($accessRules | Where-Object {($_.FileSystemRights.ToString().Split(',') | % {$_.trim()} | ? {$rules -contains $_}) -ne $null})
  $match.count -gt 0
}