Skip to content

Ability to import Modules during startup of PowerShell runspaceΒ #48

@FabienTschanz

Description

@FabienTschanz

Hey there, awesome module you did! I'm currently checking for parallelization in the Microsoft365DSC module when exporting configuration, so that we can speed up the export by a couple of times.

Right now, the export might run faster than sequential, but because we're dynamically loading modules into the session, it might (on shorter runs) be the opposite way. We're still talking about a duration of 2-5 minutes, where sequentially executing the export can be almost as fast as the parallel run because of the module import.

After tracing the module import down, it seems that when the PowerShell runspace is open and commands are executed, loading modules across multiple runspaces at the same time slows down the import massively compared to running it in a single session. Is it possible to "share" a common module state or have the runspaces import the modules during creation? I don't know if that is actually faster or not, but I'm curious about it. Adding them to the session state is pretty easy using the ImportPSModule method of the InitialSessionState class.

Thank you!

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions