Lets assume we have a module called ImportTest
like this:
# ~\Modules\ImportTest\ImportTest.psm1
. ("{0}\TestClass.ps1" -f $PSScriptRoot)
# skip Export-ModuleMember because there is no explicit way to export classes
# ~\Modules\ImportTest\TestClass.ps1
Class TestClass {
[string] $OS
[string] $Name
}
As I know from this, it is possible to use the keyword using
to load a module with classes. So I tried this:
using module ImportTest
# skip Import-Module ImportTest because it does not load classes.
$myclass = [TestClass]::new()
But it still doesn't find the definition. If I define the class in the script module file (ImportTest.psm1)
itself it works.
Did I miss anything? - As I know there is no other way to do the dotsourcing
or to export it in a other scope.