ps-scripts/Windows/getAcl.ps1

25 lines
814 B
PowerShell
Raw Permalink Normal View History

#On demande à l'user de rentrer le chemin source
$entPath = Read-Host "Chemin vers le dossier a examiner : "
#et le chemin cible
$outPath = Read-Host "Ou stocker le CSV : "
#On active la recursion
$FolderPath = dir -Directory -Path "$entPath" -Recurse -Force
$Report = @()
#Une petite boucle pour recuperer les ACL de tous les dossiers
Foreach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
foreach ($Access in $acl.Access)
{
$Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
Group or
User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Report += New-Object -TypeName PSObject -Property $Properties
}
}
#On stocke le rapport la ou l'user veut
$Report | Export-Csv -path "$outPath"