$drive
= "F:\"
$fileName
= "C:\Audits\FDrive_Audit_$((Get-Date -Format d).Replace(" ","_").replace("/","-").Replace(":",'-')).csv"
$ACL_Report
= @()
$Stack
= New-Object
System.Collections.Stack
function
getPermissions($folder)
{
$ACL_Report = @()
foreach($reference
in (Get-ACL
$folder |
%{$_.Access}))
{
$aclObj =
New-Object psobject
$aclObj |
Add-Member -MemberType
NoteProperty -Name
'Path' -Value
$folder
$aclObj |
Add-Member -MemberType
NoteProperty -Name
'Account' -Value
$reference.IdentityReference
$aclObj |
Add-Member -MemberType
NoteProperty -Name
'Access' -Value
$reference.FileSystemRights
$aclObj |
Add-Member -MemberType
NoteProperty -Name
'Inherited' -Value
$reference.IsInherited
$aclObj |
Add-Member -MemberType
NoteProperty -Name
'Inheritance' -Value
$reference.InheritanceFlags
$aclObj |
Add-Member -MemberType
NoteProperty -Name
'Propagation' -Value
$reference.PropagationFlags
$ACL_Report += $aclObj
}
$ACL_Report += " "
$ACL_Report | Export-Csv $fileName -NoTypeInformation
-Append
}
function
create-Queue($currentFolder)
{
foreach($folder
in (Get-ChildItem
$currentFolder -Directory))
{
getPermissions $folder.FullName
$Stack.Push($folder.FullName)
create-Queue $stack.Pop()
}
}
create-Queue
$drive
No comments:
Post a Comment