I had been running PowerCLI 5.8 R1; today I upgraded to 6.0 R3. And my PowerShell profile broke ... I used to use this, as my PowerShell profile:
IF (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction "SilentlyContinue")
{
# Running PowerCLI
Connect-VIServer ....
}
ELSE
{
# NOT running PowerCLI
Import-Module ActiveDirectory
}
This checked to see if VMware support was loaded, and - if so - connect me to my vCenter. If VMware support was not loaded, it would import various Microsoft-specific modules. Worked like a charm,
However, since upgrading to PowerCLI 6.0 Release 3, this doesn't work. Which is odd, since that snapin still gets loaded, even in 6.0 R3, as shown by "Get-PSSnapin" after starting PowerCLI.
I tried changing the test to Get-Module, and it still failed. I had it write out the list of loaded snapins/modules, and no VMware-related entries showed up.
Basically, it looks like the profile is now being executed *before* the Initialize-PowerCLIEnvironment.ps1 (which actually loads all the VMware snapins and modules). And so the IF test will fail, as the snapins/modules are not yet loaded.
Can anyone confirm? And - more to the point - how can I get it to do the old behavior (i.e., if VMware support is loaded, then automatically connect to vCenter; if not, load up other modules.