So I upgraded to WMF 4.0 to get access to new DSC cmdlets. This seems to have broken the PowerCLI snapins. I usually add the snapins manually or via my Powershell profile. As can be seen below I receive an error message for each of the snapins.
Get-PSSnapin -Registered VMware* | Add-PSSnapin
Add-PSSnapin : Cannot load Windows PowerShell snap-in VMware.DeployAutomation because of the following error: Unable to cast object of type
'VMware.DeployAutomation.Snapin.DeploySnapin' to type 'System.Management.Automation.CustomPSSnapIn'.
At C:\Users\Herschelle\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1:2 char:36
+ Get-PSSnapin -Registered VMware* | Add-PSSnapin
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (VMware.DeployAutomation:String) [Add-PSSnapin], PSSnapInException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
When I attempt to run the PowerCLI from the shortcut the following message is presented:
WARNING: The following errors occurred when loading console C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1: Cannot load Windows PowerShell snap-in VMware.VimAutomation.Core because of the following error: Unable to cast object of type 'VMware.VimAutomation.ViCore.Cmdlets.Vim4PSSnapIn' to type 'System.Management.Automation.CustomPSSnapIn'. Cannot load Windows PowerShell snap-in VMware.VimAutomation.Vds because of the following error: Unable to cast object of type 'VMware.VimAutomation.Vds.Commands.VdsSnapin' to type 'System.Management.Automation.CustomPSSnapIn'. Command '. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"' could not be run because some Windows PowerShell Snap-Ins did not load.
Since I cannot run PowerCLI to use the cmdlets to check the version I am resort to checking the version of PowerCLI manually.
C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\VMware.Vim.dll
Right click the file: VMware.Vim.dll
Select Properties -> Details -> File Description
Value: PowerCLI Views for vSphere 5.1.0 build 980749
The release of PowerCLI 5.1 introduced support of WMF (Powershell) 3.0.
PowerCLI 5.5 Release 2 introduced support for WMF (Powershell) 4.0.
I installed PowerCLI 5.5 and then 5.8 both exhibited the results as above.
I then uninstalled PowerCLI, VIX and the Remote Control Plugin.
I did a repair on .NET Framework 4.5.1 (which is a pre-req for WMF 4.0)
I had to do a Disk Cleanup and remove all the Microsoft update uninstall packages to clear enough room on the C: drive for the Repair to work.
Restarted the computer.
Confirmed in Powershell that no VMware Plugins were registered by using the command
Get-PSSnapin -Registered VMware*
Reinstalled PowerCLI 5.8
Still getting the same errors.
Next stop uninstalling WMF 4.0.
Control Panel -> Programs and Features -> View installed updates
Find Microsoft Windows Management Framework 4.0 (KB2819745)
Right click and select Uninstall
or for the commandline version
wusa /uninstall /kb:2819745
Either way you will require a restart of the system after the uninstall.
Was unsuccessful uninstalling the update as I had done a Disk Cleanup on my workstation to clear space on my C: drive. So now all that is left is to install WMF4.0 again and pray it works.
Open cmd.exe as Administrator
wusa.exe C:\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu /quiet /log
A restart was not required. Most likely due to the fact the system was unable to successfully uninstall in the first place.
Result:
PowerCLI now works. As does loading the VMware SnapIns in the ISE.
Next time I will simply try reinstalling WMF first. 🙂
Solution:
Upgrade PowerCLI to 5.5 Release 2 or greater (for WMF4.0 support)
and
Reinstall Windows Management Framework 4.0
Environmental:
Powershell: 4.0
PowerCLI: 5.1 R2
References:
PowerCLI 5.1 Release 2 Patch 1 Release Notes
New Release PowerCLI 5.5 Release 2