Hello All,
I'm hoping someone can help me out with making GET-ACL quicker?
Scenario:
I need to use Get-Acl on over 1million files and folders in a directory root,
and then filter on just the ones which have Inheritance set to $false.
This is my current code (which take days to run!):
## Loop each file and folder in RootPath
Foreach ($Item in $FilesAndFolders){
TRY{
Write-Verbose -message "[TRY] Getting ACLs for: $item" -verbose
$ACLs = get-acl $Item.fullname | ForEach-Object {$_.Access}
Foreach ($ACL in $ACLs){
$ObjectOut = New-Object -TypeName PsObject
$ObjectOut | Add-Member -MemberType NoteProperty -Name "Path"
-Value $Item.FullName.ToString()
$ObjectOut | Add-Member -MemberType NoteProperty -Name
"IdentityReference" -Value $ACL.IdentityReference.ToString()
$ObjectOut | Add-Member -MemberType NoteProperty -Name
"AccessControlType" -Value $ACL.AccessControlType.ToString()
$ObjectOut | Add-Member -MemberType NoteProperty -Name
"InheritanceFlags" -Value $ACL.InheritanceFlags
$ObjectOut | Add-Member -MemberType NoteProperty -Name
"PropagationFlags" -Value $ACL.PropagationFlags
$ObjectOut | Add-Member -MemberType NoteProperty -Name
"FileSystemRights" -Value $ACL.FileSystemRights.ToString()
$ObjectOut | Add-Member -MemberType NoteProperty -Name
"IsInherited" -Value $ACL.IsInherited
$ACLList += $ObjectOut
}
}
CATCH{
Write-Warning "[CATCH] ERROR getting ACL for $($item.fullname)"
-Verbose
$ACLErrorsLog += "ERROR getting ACL for $($item.fullname)"
}
Does anyone know a way to speed up the getting of ACL's, maybe by filtering out
the non-inherited objects ?
Any help much appreciated!
Thank you,
Jason
This email, the information therein and any attached materials (collectively
the "Email") are intended only for the addressee(s) and may contain
confidential, proprietary, copyrighted and/or privileged material. If you have
received this Email in error please delete it and notify the sender
immediately. This Email remains the property of Brevan Howard, which reserves
the right to require its return (together with any copies or extracts thereof)
at any time upon request. Any unauthorised review, retransmission,
dissemination, forwarding, printing, copying or other use of this Email is
prohibited. Brevan Howard may be legally required to review and retain outgoing
and incoming email and produce it to regulatory authorities and others with
legal rights to the information. Internet communications cannot be guaranteed
to be secure or error free as information could be intercepted, changed
corrupted, lost, arrive late or contain viruses. Brevan Howard accepts no
liability for any errors or omissions in this Email which arise as a result of
internet transmission. This Email is not an official confirmation of any
transaction. Any comments or statements made herein do not necessarily reflect
the views of Brevan Howard.
This Email is not an offer to sell or solicitation of an offer to buy any
security or investment. It does not constitute or contain any investment advice
and is being made without regard to the recipients investment objectives,
financial situation or means. Past Performance is not an indicator of future
results and Brevan Howard provides no assurance that future results will be
consistent with any information provided herein or attached hereto. Brevan
Howard and the sender make no warranties regarding the accuracy or completeness
of the information in this Email and it should not be relied upon and is
subject to change without notice. Brevan Howard and its representatives,
officers and employees accept no responsibility for any losses suffered as a
result of reliance on the information in this Email or the reliability,
accuracy, or completeness thereof.
In this Email, "Brevan Howard" means Brevan Howard Asset Management LLP
("BHAM"), Brevan Howard Inc., Brevan Howard (Israel) Ltd and their respective
affiliates. BHAM is a limited liability partnership authorised and regulated by
the Financial Conduct Authority of the United Kingdom and registered in England
& Wales (reg. no. OC302636).