forked from jjmolerof/PowerShellScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheck-ADAcl.ps1
More file actions
49 lines (38 loc) · 1.13 KB
/
Copy pathCheck-ADAcl.ps1
File metadata and controls
49 lines (38 loc) · 1.13 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[ValidateNotNull()]
[String]$Identity,
[Parameter(Mandatory=$False)]
[ValidateNotNull()]
[String]$OU
)
$currentlocation = Get-Location
Set-Location ad:
$Users = Get-ADUser -SearchBase $OU -Filter *
foreach ($User in $Users) {
$Acls = (Get-Acl $User.DistinguishedName).Access | where {$_.IdentityReference -like $Identity -and $_.ActiveDirectoryRights -eq "ExtendedRight" -and $_.IdentityReference -notlike "NT AUTHORITY\SELF"}
foreach ($Acl in $Acls) {
if ($Acl.ObjectType) {
$Properties = @{
"User"=$User.Name
"Identity"=$Acl.IdentityReference
"Type"=$Acl.AccessControlType
"Rights"= (Get-ADObject -SearchBase (Get-ADRootDSE).ConfigurationNamingContext -Filter {(objectclass -eq "controlAccessRight") -and (rightsguid -eq $Acl.ObjectType)} -Properties RightsGuid,DisplayName).DisplayName
}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj
}
}
if (!$Acls) {
$Properties = @{
"User"=$User.Name
"Identity"= "No Data"
"Type"= "No Data"
"Rights"= "No Data"
}
$Obj = New-Object -TypeName PSObject -Property $Properties
Write-Output $Obj
}
}
Set-Location $currentlocation