PowerShell Class Inheritance from separate file using Import-Module
What am I doing wrong here - or does PowerShell v5 not support separate class files and inheritance?
foo.ps1:
class foo
{
[STRING] $test = 'Hello World';
[STRING] PrintTest()
{
return $this.test;
}
}
bar.ps1:
Import-Module "$PSScriptRoot\foo.ps1"
class bar : foo
{ }
CONSOLE
PS C:\Script> Import-Module ./bar.ps1;
PS C:\Script> $myBar = New-Object bar;
PS C:\Script> $myBar.PrintTest();
Method invocation failed because [bar] does not contain a method named 'PrintTest'.
If it put the foo and bar classes in the same file it works fine. However the classes I'm building are rather large and I want to separate them.