12 Replies Latest reply on Jun 7, 2019 7:33 AM by it_team_mufg_br

    Cannot connect to vCenter server

    alexander_d Novice

      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.

        • 1. Re: Cannot connect to vCenter server
          LucD Guru
          Community WarriorsvExpertUser Moderators

          What a challenging setup

           

          Why can't you remove 5.5?
          You can not Uninstall via Programs & Features?
          You can not delete the folders?

           

          How did you get that strange folder under Modules?

          That's not where PowerCLI module normally go.

          • 2. Re: Cannot connect to vCenter server
            alexander_d Novice

            Hi!

            I replaced actual path with *****

            In fact it's somewhere on a D drive.

            I cannot modify existing PowerCLI because it's being used by set of scripts that were developed a long ago and no one will adjust it to newer PowerCLI version.

            Plus this PowerCLI version is a part of a solution build, so i'll have to write a sh***t ton of papers to change it without entire solution update.

            So what I'm actually doing is importing it on the fly. removing all the loaded PowerCLI modules and snapins first.

            It perfectly works with PowerShell version 6.5 and higher (with powershell 3,4 and 5). But doesn't work with 5.5 .   I performed a test and removed PowerCLI 5.5. And everything works.... but as mentioned earlier - i must keep existing PowerCLI and load newer version on the fly.

            • 3. Re: Cannot connect to vCenter server
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Since PowerCLI 5.5 was not installed in any of the "standard" locations, why can't you just start PowerShell with an adapted $env:PSModulePath, depending on which version you want to use.

              If you want to use 11.2, you should only that folder on the D-drive to $env:PSModulePath and make sure the C:\Program Files (x86) is not in there.

               

              You can ask the question on which PowerCLI in your PS profile, and then take appropriate action.

              • 4. Re: Cannot connect to vCenter server
                alexander_d Novice

                PowerCLI is installed in standard Program files folder.

                If you take a look at the code I gave - I do exactly what you're saying. but it doesn't work )

                • 5. Re: Cannot connect to vCenter server
                  LucD Guru
                  vExpertUser ModeratorsCommunity Warriors

                  The version in the error is for the DLL that can not be loaded, which is not necessarily the exact build number of the module.

                  When you look at Properties-Details of the VMware.Vim.dll you should see the number of the error message.

                   

                  I checked, but for the me the DLL version says 6.7.0.1825 (not the same as you have in your error message).
                  Could that be a typo?

                  dll.jpg

                  • 6. Re: Cannot connect to vCenter server
                    alexander_d Novice

                    I'll check tomorrow. can be a typo.

                    • 7. Re: Cannot connect to vCenter server
                      alexander_d Novice

                      Ok, here we go...

                      PS D:\Modules> $PSVersionTable

                       

                      Name                           Value

                      ----                           -----

                      PSVersion                      3.0

                      WSManStackVersion              3.0

                      SerializationVersion           1.1.0.1

                      CLRVersion                     4.0.30319.18449

                      BuildVersion                   6.2.9200.22199

                      PSCompatibleVersions           {1.0, 2.0, 3.0}

                      PSRemotingProtocolVersion      2.2

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

                      PS D:\Modules> $env:PSModulePath

                       

                      C:\Users\a\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;D:\Program Fil

                      es (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Program Files (x86)\Cisco\Cisco UCS PowerTool\Modules\

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

                      PS D:\Modules> $PSVersionTable

                       

                      Name                           Value

                      ----                           -----

                      PSVersion                      3.0

                      WSManStackVersion              3.0

                      SerializationVersion           1.1.0.1

                      CLRVersion                     4.0.30319.18449

                      BuildVersion                   6.2.9200.22199

                      PSCompatibleVersions           {1.0, 2.0, 3.0}

                      PSRemotingProtocolVersion      2.2

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

                      PS D:\Modules> Get-Module

                       

                      ModuleType Name                                ExportedCommands

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

                      Manifest   Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}

                      Manifest   Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}

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

                      PS D:\Modules> Get-PSSnapin

                       

                      Name        : Microsoft.PowerShell.Core

                      PSVersion   : 3.0

                      Description : This Windows PowerShell snap-in contains cmdlets used to manage components of Windows PowerShell.

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

                      PS D:\Modules> Get-Module -ListAvailable

                       

                          Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

                       

                      ModuleType Name                                ExportedCommands

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

                      Manifest   ActiveDirectory                     {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-A...

                      Manifest   AppLocker                           {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPoli...

                      Manifest   Appx                                {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-Ap...

                      Manifest   BitsTransfer                        {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTr...

                      Manifest   BranchCache                         {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowng...

                      Manifest   CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSes...

                      Manifest   DirectAccessClientComponents        {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelect...

                      Script     Dism                                {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsPackage, C...

                      Manifest   DnsClient                           {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientC...

                      Manifest   DnsServer                           {Add-DnsServerConditionalForwarderZone, Add-DnsServerDirectoryPartiti...

                      Manifest   GroupPolicy                         {Backup-GPO, Block-GPInheritance, Copy-GPO, Get-GPInheritance...}

                      Manifest   iSCSI                               {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-IscsiTargetPort...

                      Manifest   IscsiTarget                         {Add-ClusteriSCSITargetServerRole, Add-IscsiVirtualDiskTargetMapping,...

                      Script     ISE                                 {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}

                      Manifest   Kds                                 {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguratio...

                      Manifest   Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}

                      Manifest   Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}

                      Manifest   Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}

                      Manifest   Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}

                      Manifest   Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}

                      Manifest   Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSM...

                      Manifest   MsDtc                               {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransaction, Joi...

                      Manifest   NetAdapter                          {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChe...

                      Manifest   NetConnection                       {Get-NetConnectionProfile, Set-NetConnectionProfile}

                      Manifest   NetLbfo                             {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetL...

                      Manifest   NetQos                              {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosP...

                      Manifest   NetSecurity                         {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCr...

                      Manifest   NetSwitchTeam                       {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-N...

                      Manifest   NetTCPIP                            {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIP...

                      Manifest   NetworkConnectivityStatus           {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolic...

                      Manifest   NetworkTransition                   {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Di...

                      Manifest   PKI                                 {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-Pf...

                      Manifest   PrintManagement                     {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfigurat...

                      Script     PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, E...

                      Binary     PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}

                      Manifest   RemoteAccess                        {Add-DAAppServer, Add-DAClient, Add-DAClientDnsConfiguration, Add-DAE...

                      Manifest   ScheduledTasks                      {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregi...

                      Manifest   SecureBoot                          {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Form...

                      Manifest   SmbShare                            {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess...}

                      Manifest   Storage                             {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDi...

                      Manifest   TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-TroubleshootingPack}

                      Manifest   TrustedPlatformModule               {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}

                      Manifest   VpnClient                           {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnC...

                      Manifest   Wdac                                {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}

                      Manifest   WebAdministration                   {Start-WebCommitDelay, Stop-WebCommitDelay, Get-WebConfigurationLock,...

                      Manifest   Whea                                {Get-WheaMemoryPolicy, Set-WheaMemoryPolicy}

                      Manifest   WindowsDeveloperLicense             {Get-WindowsDeveloperLicense, Show-WindowsDeveloperLicenseRegistratio...

                      Script     WindowsErrorReporting               {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-Win...

                       

                          Directory: D:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules

                       

                      ModuleType Name                                ExportedCommands

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

                      Manifest   SQLASCMDLETS                        {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}

                      Manifest   SQLPS                               {Backup-SqlDatabase, Add-SqlAvailabilityDatabase, Disable-SqlAlwaysOn...

                       

                          Directory: C:\Program Files (x86)\Cisco\Cisco UCS PowerTool\Modules

                       

                      ModuleType Name                                ExportedCommands

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

                      Binary     CiscoUcsPS                          {Export-UcsXml, Export-UcsMoXml, Compare-UcsManagedObject, Start-UcsK...

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

                      PS D:\Modules> $env:PSModulePath += ";D:\Modules\VMware-PowerCLI-11.2.0.12780525"

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

                      PS D:\Modules> Get-Module -ListAvailable

                       

                         Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

                       

                      ModuleType Name                                ExportedCommands

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

                      Manifest   ActiveDirectory                     {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-A...

                      Manifest   AppLocker                           {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPoli...

                      Manifest   Appx                                {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-Ap...

                      Manifest   BitsTransfer                        {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTr...

                      Manifest   BranchCache                         {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowng...

                      Manifest   CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSes...

                      Manifest   DirectAccessClientComponents        {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelect...

                      Script     Dism                                {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsPackage, C...

                      Manifest   DnsClient                           {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientC...

                      Manifest   DnsServer                           {Add-DnsServerConditionalForwarderZone, Add-DnsServerDirectoryPartiti...

                      Manifest   GroupPolicy                         {Backup-GPO, Block-GPInheritance, Copy-GPO, Get-GPInheritance...}

                      Manifest   iSCSI                               {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-IscsiTargetPort...

                      Manifest   IscsiTarget                         {Add-ClusteriSCSITargetServerRole, Add-IscsiVirtualDiskTargetMapping,...

                      Script     ISE                                 {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}

                      Manifest   Kds                                 {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguratio...

                      Manifest   Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}

                      Manifest   Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}

                      Manifest   Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}

                      Manifest   Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}

                      Manifest   Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}

                      Manifest   Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSM...

                      Manifest   MsDtc                               {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransaction, Joi...

                      Manifest   NetAdapter                          {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChe...

                      Manifest   NetConnection                       {Get-NetConnectionProfile, Set-NetConnectionProfile}

                      Manifest   NetLbfo                             {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetL...

                      Manifest   NetQos                              {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosP...

                      Manifest   NetSecurity                         {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCr...

                      Manifest   NetSwitchTeam                       {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-N...

                      Manifest   NetTCPIP                            {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIP...

                      Manifest   NetworkConnectivityStatus           {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolic...

                      Manifest   NetworkTransition                   {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Di...

                      Manifest   PKI                                 {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-Pf...

                      Manifest   PrintManagement                     {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfigurat...

                      Script     PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, E...

                      Binary     PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}

                      Manifest   RemoteAccess                        {Add-DAAppServer, Add-DAClient, Add-DAClientDnsConfiguration, Add-DAE...

                      Manifest   ScheduledTasks                      {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregi...

                      Manifest   SecureBoot                          {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Form...

                      Manifest   SmbShare                            {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess...}

                      Manifest   Storage                             {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDi...

                      Manifest   TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-TroubleshootingPack}

                      Manifest   TrustedPlatformModule               {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}

                      Manifest   VpnClient                           {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnC...

                      Manifest   Wdac                                {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}

                      Manifest   WebAdministration                   {Start-WebCommitDelay, Stop-WebCommitDelay, Get-WebConfigurationLock,...

                      Manifest   Whea                                {Get-WheaMemoryPolicy, Set-WheaMemoryPolicy}

                      Manifest   WindowsDeveloperLicense             {Get-WindowsDeveloperLicense, Show-WindowsDeveloperLicenseRegistratio...

                      Script     WindowsErrorReporting               {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-Win...

                       

                          Directory: D:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules

                       

                      ModuleType Name                                ExportedCommands

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

                      Manifest   SQLASCMDLETS                        {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}

                      Manifest   SQLPS                               {Backup-SqlDatabase, Add-SqlAvailabilityDatabase, Disable-SqlAlwaysOn...

                       

                          Directory: C:\Program Files (x86)\Cisco\Cisco UCS PowerTool\Modules

                       

                      ModuleType Name                                ExportedCommands

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

                      Binary     CiscoUcsPS                          {Export-UcsXml, Export-UcsMoXml, Compare-UcsManagedObject, Start-UcsK...

                       

                          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

                      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...}

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

                      PS D:\Modules> Import-Module VMware.PowerCLI

                      Import-Module : Exception calling "OnImportModule" with "2" argument(s): "The type initializer for

                      'VMware.VimAutomation.Storage.Interop.V1.Service.StorageServiceFactory' threw an exception."

                      At line:1 char:1

                      + Import-Module VMware.PowerCLI

                      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                          + CategoryInfo          : NotSpecified: (:) [Import-Module], MethodInvocationException

                          + FullyQualifiedErrorId : TypeInitializationException,Microsoft.PowerShell.Commands.ImportModuleCommand

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

                      PS D:\Modules> Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Scope Session -DisplayDeprecationWarnings:$false -Confirm:$false | out-null

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

                      PS D:\Modules> Connect-VIServer ********

                      Connect-VIServer : Could not load file or assembly 'VMware.Vim, Version=6.7.0.1825, Culture=neutral,

                      PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

                      At line:1 char:1

                      + Connect-VIServer nlepcms001.mev.internal

                      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                          + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], FileNotFoundException

                          + FullyQualifiedErrorId : System.IO.FileNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

                       

                      PS D:\Modules> $f = "D:\Modules\VMware-PowerCLI-11.2.0.12780525\VMware.Vim\netcoreapp2.0\VMware.Vim.dll"

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

                      PS D:\Modules> $f1 = "D:\Modules\VMware-PowerCLI-11.2.0.12780525\VMware.Vim\net45\VMware.Vim.dll"

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

                      PS D:\Modules> [System.Diagnostics.FileVersionInfo]::GetVersionInfo($f) | fl

                       

                      OriginalFilename : VMware.Vim.dll

                      FileDescription  : VMware.Vim

                      ProductName      : PowerCLI

                      Comments         : Package Description

                      CompanyName      : VMware, Inc.

                      FileName         : D:\Modules\VMware-PowerCLI-11.2.0.12780525\VMware.Vim\netcoreapp2.0\VMware.Vim.dll

                      FileVersion      : 6.7.0.1825

                      ProductVersion   : 6.7.0.12483609

                      IsDebug          : False

                      IsPatched        : False

                      IsPreRelease     : False

                      IsPrivateBuild   : False

                      IsSpecialBuild   : False

                      Language         : Language Neutral

                      LegalCopyright   : Copyright © VMware

                      LegalTrademarks  :

                      PrivateBuild     :

                      SpecialBuild     :

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

                      PS D:\Modules> [System.Diagnostics.FileVersionInfo]::GetVersionInfo($f1) | fl

                       

                      OriginalFilename : VMware.Vim.dll

                      FileDescription  : VMware.Vim

                      ProductName      : PowerCLI

                      Comments         : Package Description

                      CompanyName      : VMware, Inc.

                      FileName         : D:\Modules\VMware-PowerCLI-11.2.0.12780525\VMware.Vim\net45\VMware.Vim.dll

                      FileVersion      : 6.7.0.1825

                      ProductVersion   : 6.7.0.12483609

                      IsDebug          : False

                      IsPatched        : False

                      IsPreRelease     : False

                      IsPrivateBuild   : False

                      IsSpecialBuild   : False

                      Language         : Language Neutral

                      LegalCopyright   : Copyright © VMware

                      LegalTrademarks  :

                      PrivateBuild     :

                      SpecialBuild     :

                       

                      As you can see there is powercli loaded in the powershell session untill i do i manually with import module.

                      PowerCLI 5.5 install folder is C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI

                      Tried to add D:\Modules\VMware-PowerCLI-11.2.0.12780525\VMware.Vim\net45 and D:\Modules\VMware-PowerCLI-11.2.0.12780525\VMware.Vim\netcoreapp2.0 to $env:PSModulePath - no luck.

                      Any ideas?

                      • 8. Re: Cannot connect to vCenter server
                        LucD Guru
                        vExpertUser ModeratorsCommunity Warriors

                        So the module version was a typo.

                        And what a strange environment.

                         

                        I see that you are still using PS v3.
                        That means no module autoloading.

                         

                        The netcoreapp2.0 doesn't play in this.

                        That folder is only used when you are running PS v6.*

                         

                        Windows 2012 is not in the compatibility matrix (WIndows 2012 R2 is).

                         

                        And PowerCLI 5.5, which you still seem to need, is not supported with vSphere  6.7

                         

                        Given all that, is can't really try to replicate what you are seeing.
                        Sorry about that.

                        • 9. Re: Cannot connect to vCenter server
                          alexander_d Novice

                          Well...

                          We're using vSphere 5.5 here. In 6.0+ environments everything works perfectly.

                          So i don't need any new fancy stuff besides bugfix with Get-VIEvent (when -MaxSample is limited by 7000 events).

                          The real painis that this script (actully there is a set of scripts) should be used in variuos infras (ranged from vsphere 5.5 to 6.5 with powershell versions from 3 to 6). So that's why i try to encapsulate stuff as much as possible.

                          • 10. Re: Cannot connect to vCenter server
                            alexander_d Novice

                            So any idea why it cannot find those dll's?

                            • 11. Re: Cannot connect to vCenter server
                              Jordan_K Lurker

                              I have the same issue as well. Just downloaded and installed the Powercli tools.
                              So far I could not manage to find a fix.

                              • 12. Re: Cannot connect to vCenter server
                                it_team_mufg_br Lurker

                                The following command worked for me:

                                Get-Module -Name VMware* -ListAvailable | Import-Module