proxb / PoshRSJob

Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.
MIT License
541 stars 87 forks source link

Unable to Access Function in Module from Start-RSJob #184

Closed adamfortuno closed 6 years ago

adamfortuno commented 6 years ago

I'm running PoshRSJob v1.7.4.4 on Powershell v5.1.15063.1029 on Windows 10.

I'm navigating to a folder named "Coffee.Application" with the following files:

  1. Coffee.Application.ps1
  2. Coffee.Application.psm1

I then run the following:

Start-RSJob -ScriptBlock { Get-CoffeeDBConnectionString } `
    -Name t1 `
    -ModulesToImport .\Coffee.Application.psm1

Receive-RSJob -Name t1

Receive-RSJob -Name t1, returns the following error:

The term 'Get-Foo' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The function Get-Foo is in the module Coffee.Application. I expected the thread to be able to execute the Get-Foo function in the Coffee.Application module.

The module's script file is in the current workspace. I can load the module into the active session with the following:

import-module .\Coffee.Application.psm1

Once loaded, I can access any exposed functions.

I have tried closing all session. Starting a fresh session and making the call to Start-RSJob the first call made.

MVKozlov commented 6 years ago

unlike Import-Module, -ModulesToImport parameter supports module name, but not module path.

When commit #178 will be accepted it will work

adamfortuno commented 6 years ago

If the function only accepts the module's name, do I need to keep the module's folder/files in the user or global module path?

MVKozlov commented 6 years ago

Why did not you give yourself a chance to try ? ;-)

...both sopported.

adamfortuno commented 6 years ago

That worked.

Thank you @MVKozlov!