Quantcast
Channel: VMware Communities : All Content - VMware PowerCLI
Viewing all articles
Browse latest Browse all 16717

Cannot connect to vCenter server

$
0
0

Hi!

I'm trying to connec to to a vCenter server from powershell session with PowerCLI module loaded but receive the following error:

Connect-VIServer : Could not load file or assembly 'VMware.Vim, Version=6.7.0.185, Culture=neutral,PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.At line:1 char:1

Here is the script code:

 

#Unload existing PowerCLI

If (Get-PSSnapin | ? {$_.Name -like "VMware*"}) { Get-PSSnapin VMware* | Remove-PSSnapin }

If (Get-Module | ? {$_.Name -like "VMware*"}) { Get-Module VMware* | Remove-Module -Force }

 

#Import PowerCLI v11

$ModulePath = $PSScriptRoot +"\Modules\VMware-PowerCLI-11.2.0.12780525"

$env:PSModulePath = $ModulePath

Import-Module VMware.VimAutomation.Core

 

#Set PowerCLI configuration

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Scope Session -DisplayDeprecationWarnings:$false -Confirm:$false | out-null

Connect-VIServer ********

....

....

 

$env:PSModulePath variable does not contain old PowerCLI paths and after loading new path to $env:PSModulePath shows :

PS C:\Users\a> get-module -listavailable

 

    Directory: D:\*******\Modules\VMware-PowerCLI-11.2.0.12780525

 

ModuleType Name                                ExportedCommands

---------- ----                                ----------------

Script     VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-DeployRule...}

Script     VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfil...

Manifest   VMware.PowerCLI

Script     VMware.Vim

Script     VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}

Script     VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog...}

Script     VMware.VimAutomation.Common

Script     VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-...

Script     VMware.VimAutomation.Hcx            {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance, Get-HCXAp...

Script     VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}

Script     VMware.VimAutomation.License        Get-LicenseDataManager

Script     VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtPolicyService, Ge...

Script     VMware.VimAutomation.Sdk            {Get-ErrorReport, Get-InstallPath, Get-PSVersion}

Script     VMware.VimAutomation.Security       {Get-SecurityInfo, Get-VTpm, Get-VTpmCertificate, Get-VTpmCSR...}

Script     VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}

Script     VMware.VimAutomation.Storage        {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePolicy, Get-K...

Script     VMware.VimAutomation.StorageUtility Update-VmfsDatastore

Script     VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPor...

Script     VMware.VimAutomation.Vmc            {Connect-Vmc, Disconnect-Vmc, Get-VmcSddcNetworkService, Get-VmcServi...

Script     VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefin...

Script     VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance...}

 

Get-Module also shows different VMware.Vim that in the error:

PS C:\Users\a> Get-Module | select  ModuleType,name,version

                             ModuleType Name                                    Version

                             ---------- ----                                    -------

                               Manifest Microsoft.PowerShell.Management         3.0.0.0

                               Manifest Microsoft.PowerShell.Utility                      3.0.0.0

                                 Script VMware.Vim                                            6.7.0.12483609

                                 Script VMware.VimAutomation.Cis.Core           11.2.0.12483642

                                 Script VMware.VimAutomation.Common             11.2.0.12483627

                                 Script VMware.VimAutomation.Core               11.2.0.12483638

                                 Script VMware.VimAutomation.Sdk                11.2.0.12483635

 

Which is quite weird imho...

 

PowerCLI 5.5 is installed on the following machine (do not ask me to remove or update it, I cannot modify it). If i remove PowerCLI 5.5 from the system- everything works fine. But i cannot remove it.

Any ideas how can I resolve it and import PowerCLI 11 without removing 5.5 into a powershell session?

P.S. OS is w2012 (not R2), and it is isolated from the Internet.


Viewing all articles
Browse latest Browse all 16717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>