VMware recently converted their PowerCLI product from PSSnapin format to modules. So I am trying to update my scripts to use these new modules instead of the old snapins. If I open a plain old PowerShell console, I can run the PowerCLI cmdlets no problem with having to "do anything" - I don't have to import-module, it just magically works. However if I run those same cmdlets in a script I wrote - it tells me unknown command.
In order to get my script to work, I have to import the module first: "Import-Module VMware.VimAutomation.Core"
Now this is not a big deal - just one extra line. But I am confused why I have to do this. Why does a PS console work fine without have to use import-module, but a script does not? I am pretty new to modules - everything I have used in the past has always been snapins (PowerCLI, Exchange, and Quest ActiveRoles Management Shell). Everything I have read suggests modules are plug-n-play. Do scripts need to be handled in a different way? One thing I did notice is that the VMware module shows nothing listed for "ExportedCommands" when I run a "Get-Module -listavailable" - does this make it required to import first? If so, why don't I have to do this in the PS console and only in scripts?
Thanks
NK