Skip to content

Instantly share code, notes, and snippets.

@1RedOne
Created December 18, 2015 20:20
Show Gist options
  • Save 1RedOne/76e5928925b11a8e42eb to your computer and use it in GitHub Desktop.
Save 1RedOne/76e5928925b11a8e42eb to your computer and use it in GitHub Desktop.
Get-ACLs for a list of folders, writing out to an Excel sheet
$ErrorActionPreference = "Stop"
$Excel = new-Object -comobject Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Cells.Item(1,1) = "Folder Name"
$Sheet.Cells.Item(1,2) = "Folder Permissions (allow)"
$Sheet.Cells.Item(1,3) = "Folder Permissions (Deny)"
$intRow = 2
$WorkBook = $Sheet.UsedRange
$WorkBook.Font.Bold = $True
$data = dir
foreach ($head in $data)
{
$acl = (Get-Acl $head).Access
$Permission = $acl | ? AccessControlType -ne 'Deny' | select -ExpandProperty IdentityReference
$Sheet.Cells.Item($intRow, 1) = $head
$Sheet.Cells.Item($intRow, 2) = $Permission -join "`n"
$Sheet.Cells.Item($intRow, 3) = ($acl | ? AccessControlType -eq 'Deny' | select -expand IdentityReference) -join "`n"
$intRow = $intRow + 1
}
$WorkBook.EntireColumn.AutoFit()
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).Font.Bold = $True
$Sheet.Cells.Item($intRow,1) = "Folder Permissons Report"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment