【发布时间】:2018-07-20 10:55:20
【问题描述】:
我正在尝试使用第一个函数获取目录的所有权限,并使用第二个函数获取继承中断的文件夹。然后我想使用第三个函数输出他们两个,但我得到的只是第一个结果,没有第二个“权限”!
function Get-Permissions3($folder) {
$Paths = Get-ChildItem $folder -Recurse
foreach ($p in $Paths) {
$Permissions = (Get-Acl $p.FullName).Access
$Permissiontable = $Permissions |
Select-Object @{name="FullName";expression={$p.FullName}},
@{name="IdentityReference";expression={$_.IdentityReference}},
@{name="FileSystemRights";expression={$_.FileSystemRights}},
@{name="IsInherited";expression={$_.IsInherited}}
$Permissiontable
}
}
function Get-BrokenInheritance($Directory) {
$D = Get-ChildItem $Directory -Directory -Recurse |
Get-Acl |
where {$_.Access.IsInherited -eq $false}
$BrokenInheritance = $D | Select-Object @{name="Without Inheritance";expression={$_.Path}}
$BrokenInheritance
}
function Get-FolderAnalysis($Path) {
Write-Output "Output Permissions"
Get-Permissions3($Path)
Write-Output "Output Broken Inheritance"
Get-BrokenInheritance($Path)
}
【问题讨论】:
标签: powershell hashtable