VMware PowerCLI 10 Setup

I found that the latest version of PowerCLI 10 ran fine in 32-bit mode but VS Code, Powershell ISE, or Powershell console in 64-bit mode were unable to load the module.  I would get the following errors when trying to import the newly installed module:

  • Could not load file or assembly ‘log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304’
    or one of its dependencies. The system cannot find the file specified.
  • Unable to find type [VMware.VimAutomation.Sdk.Interop.V1.CoreServiceFactory]

Quick fix:

Install-Module -Name VMware.PowerCLI 
#accept repo warning and install

#copy over file to fix 64-bit issue
$newDir = "C:\Windows\assembly\GAC_64\log4net\1.2.10.0__692fbea5521e1304"
New-Item $newDir -ItemType directory -Force
$file = gci "C:\Program Files\WindowsPowerShell\Modules\VMware.VimAutomation.Sdk" | select -last 1 | gci -Recurse -Filter "log4net.dll" | select -first 1
Copy-Item $file.FullName $newDir

#verify log4net.dll has copied over
Get-ChildItem $newDir

#close all instances of VS Code, Powershell ISE, or Powershell console
#Open x64 powershell and run import-module vmware.powercli