WahlNetwork / vester

Easily validate and remediate your vSphere configuration
https://wahlnetwork.com
Apache License 2.0
146 stars 45 forks source link

Auto-Import of VMware.VimAutomation.Core #74

Closed brianbunke closed 8 years ago

brianbunke commented 8 years ago

So, 1cebb28 ("Move VMware module to external dependencies for PoSh Gallery") introduced an interesting problem.

When VMware.VimAutomation.Core was a "Required Module," I could open a console and do this:

Import-Module .\Vester
# Note that VMware.VimAutomation.Core automatically loaded as part of the Vester import
Connect-VIServer vcsa.home.lab

Now, after moving to an "External Module Dependency," it doesn't work:

Connect-VIServer : The term 'Connect-VIServer' is not recognized as the name of a cmdlet, [blah blah blah]

Furthermore, Door A:

Import-Module .\Vester
Connect-VIServer vcsa.home.lab

Connect-VIServer : The term 'Connect-VIServer' is not recognized as the name of a cmdlet, [blah blah blah]

# Fine, I'll manually import
Import-Module VMware.VimAutomation.Core
Connect-VIServer vcsa.home.lab

Connect-VIServer : The term 'Connect-VIServer' is not recognized as the name of a cmdlet, [blah blah blah]

And Door B:

# Guess I'll try bringing in PowerCLI first?
Import-Module VMware.VimAutomation.Core
Import-Module .\Vester
Connect-VIServer vcsa.home.lab

# lol jk I'm fine

Any quick suggestions on how we should ideally handle this within the .psd1 file?

brianbunke commented 8 years ago

Both "doors" above also return inaccurate results for Get-Command -Module Vester

chriswahl commented 8 years ago

I'm not sure on a quick fix unless the PowerCLI code is added to the Gallery. Otherwise, having it as a dependency makes the Gallery upload fail (can't find the module ... abort).

Would a #requires statement not work?

brianbunke commented 8 years ago

78 works for me with PowerCLI 6.3 and 6.5.

EDIT: That fix actually only works in PowerCLI 6.5, but that's ok.

chriswahl commented 8 years ago

Merged. That works for me, too. And I agree that we should continue to encourage people to use the latest version of PowerCLI. Especially since VMware officially recommends that.