PSHTML-AD-Report icon indicating copy to clipboard operation
PSHTML-AD-Report copied to clipboard

Performance Improvements

Open shockogit opened this issue 4 years ago • 0 comments

New to this project and came across with a google search when tasked internally with creating some reports for security people. Awesome work and so helpful for people like me who have a short time frame but large remit! :)

Some performance observations from a quick glance:

$OwnerDN = Get-ADGroup -Filter { name -eq $Group.Name } -Properties managedBy | Select-Object -ExpandProperty ManagedBy
Try{
$Manager = Get-ADUser -Filter { distinguishedname -like $OwnerDN } -t | Select-Object -ExpandProperty Name
}Catch{
	write-host -ForegroundColor Yellow "Cannot resolve the manager, " $Manager " on the group " $group.name
}

So:

  1. Why not use Get-AdGroup with the DN to avoid an AD Search? Much quicker.
  2. If we add each successful lookup of the manager to a hashtable we can look it up there and avoid the call to Get-ADGroup. Much quicker!:)

I have never used GitHub or powershell so I will learn how to get involved and make a code submission over next day or two.

shockogit avatar Apr 26 '20 21:04 shockogit