{"id":557,"date":"2014-12-16T10:54:30","date_gmt":"2014-12-15T23:54:30","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=557"},"modified":"2014-12-17T13:16:34","modified_gmt":"2014-12-17T02:16:34","slug":"cannot-load-windows-powershell-snap-in-vmware-xxx","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=557","title":{"rendered":"Cannot load Windows PowerShell snap-in VMware.xxx"},"content":{"rendered":"<p>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.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nGet-PSSnapin -Registered VMware* | Add-PSSnapin\r\n\r\nAdd-PSSnapin : Cannot load Windows PowerShell snap-in VMware.DeployAutomation because of the following error: Unable to cast object of type\r\n'VMware.DeployAutomation.Snapin.DeploySnapin' to type 'System.Management.Automation.CustomPSSnapIn'.\r\nAt C:\\Users\\Herschelle\\Documents\\WindowsPowerShell\\Microsoft.PowerShellISE_profile.ps1:2 char:36\r\n+ Get-PSSnapin -Registered VMware* | Add-PSSnapin\r\n+                                    ~~~~~~~~~~~~\r\n    + CategoryInfo          : InvalidData: (VMware.DeployAutomation:String) [Add-PSSnapin], PSSnapInException\r\n    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand\r\n<\/pre>\n<p>When I attempt to run the PowerCLI from the shortcut the following message is presented:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nWARNING: The following errors occurred when loading console C:\\Program Files (x86)\\VMware\\Infrastructure\\vSphere PowerCLI\\vim.psc1:\r\nCannot load Windows PowerShell snap-in VMware.VimAutomation.Core because of the following error: Unable to cast object of type\r\n'VMware.VimAutomation.ViCore.Cmdlets.Vim4PSSnapIn' to type 'System.Management.Automation.CustomPSSnapIn'.\r\nCannot load Windows PowerShell snap-in VMware.VimAutomation.Vds because of the following error: Unable to cast object of type\r\n'VMware.VimAutomation.Vds.Commands.VdsSnapin' to type 'System.Management.Automation.CustomPSSnapIn'.\r\nCommand '. &quot;C:\\Program Files (x86)\\VMware\\Infrastructure\\vSphere PowerCLI\\Scripts\\Initialize-PowerCLIEnvironment.ps1&quot;' could not be run because some Windows PowerShell Snap-Ins did not load.\r\n<\/pre>\n<p>Since I cannot run PowerCLI to use the cmdlets to check the version I am resort to checking the version of PowerCLI manually.<\/p>\n<p>C:\\Program Files (x86)\\VMware\\Infrastructure\\vSphere PowerCLI\\VMware.Vim.dll<\/p>\n<p>Right click the file: VMware.Vim.dll<br \/>\nSelect Properties -&gt; Details -&gt; File Description<\/p>\n<p>Value: PowerCLI Views for vSphere 5.1.0 build 980749<\/p>\n<p>The release of PowerCLI 5.1 introduced support of WMF (Powershell) 3.0.<br \/>\nPowerCLI 5.5 Release 2 introduced support for WMF (Powershell) 4.0.<\/p>\n<p>I installed PowerCLI 5.5 and then 5.8 both exhibited the results as above.<\/p>\n<p>I then uninstalled PowerCLI, VIX and the Remote Control Plugin.<\/p>\n<p>I did a repair on .NET Framework 4.5.1 (which is a pre-req for WMF 4.0)<br \/>\nI 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.<\/p>\n<p>Restarted the computer.<\/p>\n<p>Confirmed in Powershell that no VMware Plugins were registered by using the command<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">Get-PSSnapin -Registered VMware*<\/pre>\n<p>Reinstalled PowerCLI 5.8<\/p>\n<p>Still getting the same errors.<br \/>\nNext stop uninstalling WMF 4.0.<\/p>\n<p>Control Panel -> Programs and Features -> View installed updates<br \/>\nFind Microsoft Windows Management Framework 4.0 (KB2819745)<br \/>\nRight click and select Uninstall<\/p>\n<p>or for the commandline version<br \/>\nwusa \/uninstall \/kb:2819745<\/p>\n<p>Either way you will require a restart of the system after the uninstall.<\/p>\n<p>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.<\/p>\n<p>Open cmd.exe as Administrator<br \/>\nwusa.exe C:\\Temp\\Windows6.1-KB2819745-x64-MultiPkg.msu \/quiet \/log<br \/>\nA restart was not required. Most likely due to the fact the system was unable to successfully uninstall in the first place.<\/p>\n<p><strong>Result<\/strong>:<br \/>\nPowerCLI now works. As does loading the VMware SnapIns in the ISE.<br \/>\nNext time I will simply try reinstalling WMF first. \ud83d\ude42<\/p>\n<p><strong>Solution<\/strong>:<br \/>\nUpgrade PowerCLI to 5.5 Release 2 or greater (for WMF4.0 support)<br \/>\nand<br \/>\nReinstall Windows Management Framework 4.0<\/p>\n<p><strong>Environmental<\/strong>:<br \/>\nPowershell: 4.0<br \/>\nPowerCLI: 5.1 R2<\/p>\n<p><strong>References<\/strong>:<br \/>\n<a title=\"PowerCLI 5.1 Release 2 Patch 1 Release Notes\" href=\"https:\/\/www.vmware.com\/support\/developer\/PowerCLI\/PowerCLI51R2\/powercli51r2-releasenotes.html\">PowerCLI 5.1 Release 2 Patch 1 Release Notes<\/a><br \/>\n<a title=\"New Release PowerCLI 5.5 Release 2\" href=\"http:\/\/blogs.vmware.com\/PowerCLI\/2014\/03\/new-release-vsphere-powercli-5-5-r2.html\">New Release PowerCLI 5.5 Release 2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 <a href=\"https:\/\/threemillion.net\/blog\/?p=557\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[49,8],"tags":[25,71],"class_list":["entry","author-admin","post-557","post","type-post","status-publish","format-standard","category-powercli","category-powershell","tag-error","tag-snapin"],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=557"}],"version-history":[{"count":11,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/557\/revisions"}],"predecessor-version":[{"id":573,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/557\/revisions\/573"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}