powershellmodulepowershell-3.0import-module

How can I import a module into powershell without waiting for it to complete?


I have a psm1 file I want to load into my $profile, but it takes long to load. I would prefer to load it "in the background" where it doesn't prevent immediate action in my powershell prompt. If I run it as a job, I don't get the functions from the psm1 file. Any ideas how I can do this? It doesn't look like there are any flags to "load in the background" from Import-Module.


Solution

  • PowerShell jobs are run in their own session. I imagine that importing the module is working fine, but just not in the PowerShell session you want. See about_Job_Details

    Why does your module take so long to load? Maybe you can improve that?