Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell在不继承的情况下获取文件夹权限_Powershell_Inheritance_Active Directory_Powershell 2.0_Acl - Fatal编程技术网

Powershell在不继承的情况下获取文件夹权限

Powershell在不继承的情况下获取文件夹权限,powershell,inheritance,active-directory,powershell-2.0,acl,Powershell,Inheritance,Active Directory,Powershell 2.0,Acl,我想知道是否有一种简单的方法可以列出一个文件夹及其所有子文件夹的权限,但一旦从上面的文件夹继承了权限,它就不应该列出该文件夹,因为这样我的列表就太大了。我有一些检查文件夹权限的工作方式代码,但现在,它还列出了具有继承权限的文件夹 $User = "Testumgebung\cbruehwiler" $UserOhneDomain = "cbruehwiler" $Path = "T:\" $List = New-Object System.Collections.Generic.List[Sys

我想知道是否有一种简单的方法可以列出一个文件夹及其所有子文件夹的权限,但一旦从上面的文件夹继承了权限,它就不应该列出该文件夹,因为这样我的列表就太大了。我有一些检查文件夹权限的工作方式代码,但现在,它还列出了具有继承权限的文件夹

$User = "Testumgebung\cbruehwiler"
$UserOhneDomain = "cbruehwiler"
$Path = "T:\"
$List = New-Object System.Collections.Generic.List[System.Object]
$Groups = Get-ADPrincipalGroupMembership $UserOhneDomain

$GroupArrayList = New-Object System.Collections.ArrayList
foreach ($Group in $Groups) {
    $GroupArrayList.Add($Group.Name) | Out-Null
}

# Fields we want in list, an array of calculated properties.
$OutputFields = @(
    @{name="Item" ;       expression={$_.Path.split(':',3)[-1]}}
    @{name="Rights" ;     expression={$Right.FileSystemRights}}
    @{name="AccessType" ; expression={$Right.AccessControlType}}
    @{name="From" ;       expression={$User}}
)
$FileSystemObjects = Get-ChildItem $Path -Recurse | ForEach-Object {Get-Acl $_.FullName}

foreach ($Item in $FileSystemObjects) {
    foreach ($Right in $Item.Access) {
        if ($Right.IdentityReference -eq $User) {
            $List.Add(($Item | Select-Object $OutputFields))
        }
    }
}

foreach ($Item in $FileSystemObjects) {
    foreach ($Right in $Item.Access) {
        foreach ($GroupArrayItem in $GroupArrayList){
            if ($Right.IdentityReference -eq ("TESTUMGEBUNG\" + $GroupArrayItem)) {
                $List.Add(($Item | Select-Object $OutputFields))
            }
        }
    }
}

$List | Out-File C:\Users\cbruehwiler\Desktop\PermissionCheck.txt

您可以使用每个访问的
ISInhered
值将其过滤掉

if($Right.IsInherited -eq $false){
    //do stuff
}