I'm working on a Quick Module CLI builder. The idea is you have my Module, which has commands like Add-QuickFunction, Add-QuickAlias, New-QuickModule, Remove-QuickCommand, etc.
As you build out the functions, your Modules continue to get built out. The plan is to create an Export-QuickModule and Export-QuickModule command, so that when you're ready to Export your module it's ready to be published, to your organization, or to a public gallery.
So the problem is two-fold.
- The exported members do not match the commands in the module
PS C:\WINDOWS\system32> Get-Module -Name QuickModuleCLI
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.1.3 QuickModuleCLI {New-QuickModule, Update-QuickModule}
Notice how it only includes 2 Exported commands. This is after I manually added Export-ModuleMember to my local system. Without having Export-ModuleMember, only New-QuickModule appears as exported.
But compare it to the actual list of Commands:
PS C:\WINDOWS\system32> Get-Command -Module QuickModuleCLI
CommandType Name Version Source
----------- ---- ------- ------
Function Add-QuickAlias 0.1.3 QuickModuleCLI
Function Add-QuickFunction 0.1.3 QuickModuleCLI
Function ConvertTo-PowershellEncodedString 0.1.3 QuickModuleCLI
Function Edit-QuickCommand 0.1.3 QuickModuleCLI
Function New-QuickModule 0.1.3 QuickModuleCLI
Function Remove-QuickCommand 0.1.3 QuickModuleCLI
Function Rename-QuickCommand 0.1.3 QuickModuleCLI
Function Reset-QuickCommand 0.1.3 QuickModuleCLI
Function Set-Env 0.1.3 QuickModuleCLI
Function Update-QuickModule 0.1.3 QuickModuleCLI
- The Nested Module isn't getting imported into the PowerShell session until after I've imported the Module. I can deal with it by adding Import-Module to my $Profile if I have to, but I just want to make sure I'm not doing anything wrong.
What this means is, after opening a new session, I see the following:
PS C:\WINDOWS\system32> Write-Test
Write-Test : The term 'Write-Test' 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 line:1 char:1
+ Write-Test
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Write-Test:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\WINDOWS\system32> Import-Module QuickModuleCLI
PS C:\WINDOWS\system32> Write-Test
Hello
I use a dynamic self-rolled PowerShell generator to update the psd1 file and add to the FunctionsToExport. You can verify that when I Import-Module, it calls the NestedModules and imports it properly. However, on the computer I use to develop this Module in, I don't need to Import-Module in order for Write-Test to appear in my PowerShell Options. Is this an environmental thing that I have to just "deal with" or is this something you that can be fixed?
The code can be found here: https://github.com/EdLichtman/QuickModuleCLI And you can try it out yourself with Import-Module QuickModuleCLI