Audit NTFS on Shares by ission 17 months ago (modification of post by DigitalAsylum view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/2125"></script>download | new post
Audit Folders/Shares and Export to Excel
- $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()
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository