-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfolderInheritance.ps1
More file actions
35 lines (26 loc) · 964 Bytes
/
folderInheritance.ps1
File metadata and controls
35 lines (26 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#
.SYNOPSIS
File / Folder Auditing script to determine which users have permissions that are *NOT* inherited.
.DESCRIPTION
Date UpdatedBy Details
08/10/2017 BW Initial coding.
#>
$path="C:\Program Files"
$outFile="myFolderInheritance.csv"
$nonInherited=new-object System.Collections.ArrayList
$folders=dir $path -Directory -recurse|get-acl|
select @{Label='Path';Expression={$_.PSPath.replace("Microsoft.PowerShell.Core\FileSystem::","")}},
@{Label='User';Expression={$_.Access.identityReference}},
@{Label='IsInherited';Expression={$_.Access.IsInherited}}|
where {$_.IsInherited -eq $false}
foreach ($item in $folders) {
$pass=0
write-host "Checking folder $($item.path)"
foreach ($user in $item.user) {
#$x=$nonInherited "$($item.Path), $($user),$($item.IsInherited[$pass])"
$x=$noninherited.add("$($item.Path), $($user),$($item.IsInherited[$pass])")
$pass=$pass++
}
}
$nonInherited|out-file -FilePath $outFile
write-host "Done."