MichaelGrafnetter / DSInternals

Directory Services Internals (DSInternals) PowerShell Module and Framework
https://www.dsinternals.com
MIT License
1.62k stars 250 forks source link

Memory consumption when running Get-ADDBAccount command #171

Open omachugh opened 9 months ago

omachugh commented 9 months ago

Hi

Using DSInternals PS Module version 4.9, seeing excessive memory consumption when running the following PS command

Get-ADDBAccount -All -DBPath $NTDSPATH -BootKey $key

To get halfway through c100k accounts is consuming about 6GB of memory.

Thx

MichaelGrafnetter commented 9 months ago

Hello @omachugh, are you saving the output of Get-ADDBAccount to a variable, or are you only processing the results through the pipeline? How large is your ntds.dit file? In environments with Credential Roaming and/or Windows Hello for Business, objects consuming 10s or 100s of KBs are quite common. And deserializing the data from DB into .NET objects also takes its toll. In my performace tests, the .NET garbage collector seemed to do its job during pipeline processing and I have not spotted any memory leaks in the interop libraries from Microsoft. I am working on a feature where you could select what account attributes to fetch. That should increase the performance on large AD databases.