Author Posts

April 1, 2016 at 5:55 am

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.

April 1, 2016 at 6:38 am

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