# encoding: ascii
# api: powershell
# title: Audit NTFS on Shares
# description: Audit Folders/Shares and Export to Excel
# version: 0.1
# author: DigitalAsylum
# license: CC0
# x-poshcode-id: 1721
# x-archived: 2016-07-20T15:59:56
# x-published: 2010-03-24T11:27:00
#
#
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$wSheet = $Excel.Worksheets.Item(1)
$wSheet.Cells.item(1,1) = "Folder Path:"
$wSheet.Cells.Item(1,2) = "Users/Groups:"
$wSheet.Cells.Item(1,3) = "Permissions:"
$wSheet.Cells.Item(1,4) = "Permissions Inherited:"
$WorkBook = $wSheet.UsedRange
$WorkBook.Interior.ColorIndex = 8
$WorkBook.Font.ColorIndex = 11
$WorkBook.Font.Bold = $True
####Change the path to the folder or share you want NTFS perms on####
$dirToAudit = Get-ChildItem -Path "c:\inetpub" -recurse | Where {$_.psIsContainer -eq $true}
$intRow = 1
foreach ($dir in $dirToAudit)
{
$colACL = Get-Acl -Path $dir.FullName
foreach ($acl in $colACL)
{
$intRow++
$wSheet.Cells.Item($intRow,1) = $dir.FullName
foreach ($accessRight in $acl.Access)
{
$wSheet.Cells.Item($intRow,2) = "$($AccessRight.IdentityReference)"
$wSheet.Cells.Item($intRow,3) = "$($AccessRight.FileSystemRights)"
$wSheet.Cells.Item($intRow,4) = $acl.AreAccessRulesProtected
$intRow++
}
}
}
$WorkBook.EntireColumn.AutoFit()