I dare say PowerShell 2.0 ISE and Modules are still a vision.
When a module depends on a another module like SQLISE on ICECreamBasic or WPK it seems natural
to use within the .psm1 file
import-module ISECreamBasic
import-module SQLParser
import-module adolib
import-module WPK
When I write a second module OracleIse, I can do similar
import-module ISECreamBasic
import-module OracleClient
import-module WPK
Seems OK so far.
Next modules can be removed using Remove-module and that fires even an event to do some clean up as removing ISE addons menu items
$mInfo = $MyInvocation.MyCommand.ScriptBlock.Module
$mInfo.OnRemove = {
Write-Host "$($MyInvocation.MyCommand.ScriptBlock.Module.name) removed on $(Get-Date)"
Remove-IseMenu OracleIse
}
Now emove on of these modules an see, which modules are left using
get-module
You see, that the removed modul removed the modules imported within too, without tribute to the fact that the other module depends on WPK and ISECreamBasic too.
Conclusion. Better do not use import-module to import module from within your modules. Import the needed modules in advance.
Have some fun trying to find work arounds for this issue.
Bernd
