Skip to content

Add ImportPSModulesFromPath support #177

@beargle

Description

@beargle

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Importing modules in background runspace jobs requires that the module be:

  • "Installed" and accessible in $env:PSModulePath
  • Passed by name to Start-RSJob using the -ModuleToImport parameter

What is the proposed behavior?
Add support for passing a custom module path, from which modules will be imported into background runspace jobs.

This should require no modification of $env:PSModulePath, and shouldn't require the module to be pre-installed on the client. Expecting something similar to how modules are specified for import in psake-config.ps1. Specific use case is a portable CI/CD pipeline that manages PowerShell module dependencies, without relying on Install-Module or a specific build server configuration.

It looks like InitialSessionState.ImportPSModulesFromPath() could work for this, but would make a hard dependency on PowerShell V3. Wasn't sure if PowerShell V2 support was still important based on #162.

Please provide a code example showing the potential feature, if applicable:
Today we pass in one or more module names to import, which have to be accessible with $env:PSModulePath

Start-RSJob -ModulesToImport @("Pester")...

Would like to be able to pass in a custom module path, from which one or more modules are imported. Assuming a directory structure of:

Dependencies/
    PowerShell/
        Modules/

We should be able to:

Start-RSJob -ModulesFromPathToImport ".\Dependencies\PowerShell\Modules"...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions