microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.52k stars 458 forks source link

Reduce memory consumption by implementing recommendations for Exchange Online PowerShell V3 module #3956

Open Borgquite opened 9 months ago

Borgquite commented 9 months ago

Description of the issue

The Exchange Online team recently posted some recommendations on reducing memory consumption of the Exchange Online PowerShell V3 module:

  1. Do not load the help package (using Connect-ExchangeOnline -SkipLoadingCmdletHelp
  2. Load only specific cmdlets which are required by a script (using Connect-ExchangeOnline -CommandName)
  3. Create a new PowerShell process for each new Exchange Online connection (using Start-Process / Exit)

Feels like some or all of these could be well used when connecting to Exchange Online using the Microsoft365DSC module - e.g. 'SkipLoadingCmdletHelp' is probably a really quick and easy win?

https://techcommunity.microsoft.com/t5/exchange-team-blog/reducing-memory-consumption-of-the-exchange-online-powershell-v3/ba-p/3970086

Microsoft 365 DSC Version

1.23.1122.1

Which workloads are affected

Exchange Online

The DSC configuration

All DSC configurations (see blog post)

Verbose logs showing the problem

N/A

Environment Information + PowerShell Version

N/A
NikCharlebois commented 8 months ago

Agreed on the -SkipLoadingCmdletHelp. We will go ahead and implement it right away. The two other recommendations however would require some more thinking and probably so fair amount of refactoring. We want to make sure MSCloudLoginAssistant continues to be an independent module outside of M365DSC. This means that we would have to add additional properties to the Connect-M365Tenant that would accept a list of command to be loaded, and that M365DSC would have to pre-determine the ones required upon connection. This in itself would require a lot of work.

andikrueger commented 8 months ago

-SkipLoadingCmdletHelp got recently added to MSCloudLoginAssistant in V 1.1.1 and is available in M365DSC starting with V 1.23.1129.1