I am trying to get all the permissions on a directory using the first function, and the folders with broken inheritance using the second function. Then I want to output the both of them using the third function, but I am getting just the first result the "permission" without the second one!
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)
}