The 'using module' statement into a ThreadJob's ScriptBlock

Copper Contributor

Hi everyone!


I have a question about the 'using module' statement in Powershell.


I have many class in different .psm1 files, wich works perfectly with 'using module' statement. But I need to import my class into a ThreadJob's ScriptBlock and 'using module' do not be used after any statements in the script. 




I do not want use the 'import-module' statement, because this statement not import class from .psm1 files, only from ps1. I would have to change all my class files to .ps1 and the 'using module' do not work with .ps1. What would entail more and more problems.


'using module' also works with relative path, import-module do not.


Exists one way to use the 'using module' into a ScriptBlock or another way to delegate the imports between the scopes?


Thanks for help!

0 Replies