clear-host $MesACLs = get-acl "C:\" $ListeACL = @() ForEach ($OneACL in $MesACLs.Access) { $OneAclResult = New-Object -TypeName PSObject $MaVariable = [string] $OneACL.IdentityReference $NomDuGroupe = $MaVariable.substring($MaVariable.indexof("\")+1) #write-host $NomDuGroupe try{ if ($NomDuGroupe -ne "Utilisa. du domaine") {$MonGroupe = Get-ADGroupMember -identity $NomDuGroupe -Recursive | select name, SamAccountName } } catch{ $MonGroupe = $null #Write-host $($_.exception.message) } $OneAclResult | Add-Member -Type NoteProperty -Name IdentityReference -Value $OneACL.IdentityReference #$MaVariable $OneAclResult | Add-Member -Type NoteProperty -Name FileOneAclResultRights -Value $OneACL.FileOneAclResultRights $OneAclResult | Add-Member -Type NoteProperty -Name IsInherited -Value $OneACL.IsInherited $OneAclResult | Add-Member -Type NoteProperty -Name AccessControlType -Value $OneACL.AccessControlType $OneAclResult | Add-Member -Type NoteProperty -Name InheritanceFlags -Value $OneACL.InheritanceFlags $ListeACL += $OneAclResult $OneAclResult = $null #Si le membre est un groupe, on ajoute les membres du groupe if ($MonGroupe-ne $null) { foreach ($UneLigne in $MonGroupe){ $OneAclResult = New-Object -TypeName PSObject $OneAclResult | Add-Member -Type NoteProperty -Name IdentityReference -Value "$NomDuGroupe : $($UneLigne.name)" $OneAclResult | Add-Member -Type NoteProperty -Name FileOneAclResultRights -Value $OneACL.FileOneAclResultRights $OneAclResult | Add-Member -Type NoteProperty -Name IsInherited -Value $OneACL.IsInherited $OneAclResult | Add-Member -Type NoteProperty -Name AccessControlType -Value $OneACL.AccessControlType $OneAclResult | Add-Member -Type NoteProperty -Name InheritanceFlags -Value $OneACL.InheritanceFlags $ListeACL += $OneAclResult $OneAclResult = $null } #write-host $NomDuGroupe } write-host "" } $ListeACL | sort-object -property IdentityReference | Format-Table #$ListeACL | Where-Object {$_.IdentityReference -match ""} | Format-Table