Issue importing a module from a module

In an effort to simplify my scripts I created a module and moved some of my functions to it. One thing that doesn’t work is a function that imports a module.

The module that I’m trying to import in my session contains several cmdlets such as Get-MW_Mailbox, Get-MW_MailboxConnector.

MyModule.psm1:

function Import-BTmodule { try { Import-Module 'C:Program Files (x86)BitTitanBitTitan PowerShellBitTitanPowerShell.dll' -Global -ErrorAction Stop } catch { Write-Host "Not able to import the BitTitan module." -ForegroundColor Red Write-Host "Error:" -ForegroundColor Red Write-Host $_.Exception.Message -ForegroundColor Red } } 

In the shell:

Import-Module MyModule Get-MW_Mailbox 

Error:

Get-MW_Mailbox : The term ‘Get-MW_Mailbox’ 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.

All of this works outside of the module. It works for other functions in this module and I added a manifest that contains FunctionsToExport. After reading about local sessions and context I added the -Global switch for Import-Module in my module.

Still I do not get the cmdlets available in my session after importing MyModule and calling Import-BTmodule. Any ideas?

submitted by /u/JetzeMellema
[link] [comments]

Leave a Reply