Importing a module from a module. Cmdlets not avaiable

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Ray Jette Ray Jette 5 months, 4 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37155
    Profile photo of Ray Jette
    Ray Jette
    Participant

    Good morning,

    The following works when I run it as is or in a fucntion:
    if (-not (Get-Module VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
    Import-Module -Name VMware.VimAutomation.Core
    }

    things like Get-VM works

    When I put it into a function in a custom module It appears to work but I can't run any of the cmdlets like Get-VM. It appears to be a scope issue. I've tried the -global parameter with Import-Module with no luck.

    How can I import a module from within another module and make the cmdlets avaiable in PowerShell? Thanks for the help.

    #37158
    Profile photo of Ray Jette
    Ray Jette
    Participant

    To add a little more information to what I am trying to do. I have a lot of PowerShell scripts I've written over the years. I'm trying to organize them by using modules.

    I have a module for my VMware functions. In this module I have a function to load the VMware modules so the caller can use the cmdlets. This works great when the function is dot sourced. When I call the function from my module the VMware cmdlets are not avaiable.

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.