-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ImportPSModulesFromPath support #177
Comments
If this looks like something that would be useful, I'm happy to put together a PR for review. Thanks! |
@beargle This sounds cool! I am definitely done with adding new features for V2 and have already moved the V2 supporting module onto its own branch. I just need to work on removing the V2 code as well as adding a warning when this module is imported from a V2 host. I should have that completed by the end of the week if you can wait until then, otherwise go ahead and do the PR and I will merge it and then begin work on removing the V2 stuff. |
btw this can be done thru |
@MVKozlov Good point about similar functionality with I haven't been able to get Regardless, PR has been raised - would appreciate any feedback you all have. Thanks! |
I this this way close to your needs $list = 'PoshWSUS', 'D:\Work\ps\test\', 'D:\Work\ps\test\PSAlphaFS\2.0.0.1\*.psm1'
$modulenames = New-Object System.Collections.ArrayList
$modulepaths = $list | ForEach-Object {
$m = $_
try {
Resolve-Path $_ -ErrorAction Stop | Select-Object -ExpandProperty Path
}
catch {
$null = $modulenames.Add($m)
}
}
$modulenames
$modulepaths here I'm split common |
Implements proxb#177
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:
$env:PSModulePath
Start-RSJob
using the-ModuleToImport
parameterWhat 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 onInstall-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
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:
We should be able to:
The text was updated successfully, but these errors were encountered: