WindowsCompatibility
WindowsCompatibility copied to clipboard
Import-Module Proxy Command
This is a great module, however it still requires scripts to be "rewritten" that have import-module natively in them.
I propose adding a command Register-WinImportModule, that will add a proxy command to import-module and use the following logic:
- If the module is available in PSCore PSModulePath, import it natively
- If not, check the Win5.1 PSModulePath. If the module is present and is supported in Core via CompatiblePSEditions manifest setting, import it natively.
- If it is present in PSModulePath but either not supported in core or CompatiblePSEditions is unspecified, Import-WinModule it.
I would end up using this in my PSCore scripts natively as well, so if I were to run, say, Import-Module ActiveDirectory, it will implicitly use the WindowsPowershell version until I get a PSCore Compatible version in place, and when I do, I don't have to rewrite my script to take advantage of it later. This would probably also require a small proxy to Get-Module to at least do a write-warning about the behavior and that Get-Module won't show all potential modules present. In the future, have the logic return all modules regardless of where they live.
I already have a version of this scaffolded, I'll be happy to write the PR if there is interest.