I know I can limit exported commands from module that is imported like this:
Import-Module C:\...\MyModule or Import-Module C:\...\MyModule\MyModule.psd1
Then I can use CmdletsToExport in .psd1.
But, what if I import module from .dll?
Import-Module C:\...\MyModule.dll
How to limit exported commands (cmdlets)?
There are cmdlets in our .dll that should be "hidden" in default and we want to allow calls of them only if some environment variable has some value.
I was thinking that Powershell maybe uses reflection to get commands from .dll, so maybe there is some way to catch some "module initialized" event where I could somehow influence what cmdlets should be exported.