It's a odd example but it gets my issue across:
FILE: Foo.psm1
class Foo
{
[OBJECT] GetSite ()
{
return Get-SPWeb -Identity 'http://mysharepointsite.com';
}
}
FILE: Bar.psm1
Using MODULE ".\Foo.psm1";
class Bar : Foo
{
Bar ()
{
Add-PSSnapin 'Microsoft.SharePoint.PowerShell';
}
}
CONSOLE:
PS C:\test> Using MODULE "C:\Test\Bar.psm1";
PS C:\test> $myBar = [Bar]::new();
PS C:\test> $myBar.GetSite();
Get-SPWeb : The term 'Get-SPWeb' 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.
At C:\Test\Foo.psm1:5 char:16
+ return Get-SPWeb -Identity 'http://mysharepointsite.com ...
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-SPWeb:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
HOWEVER ...
When the classes are in the same file, it works fine.
Any suggestions?