Skip to content
Menu
  • Home
  • vSAN
    • vSAN 7
  • vSphere
    • ESXi
    • vCenter
    • Generic vSphere Commands
  • Cloud Management
    • VCF (VMware Cloud Foundation)
    • vCloud Director
    • vRO
    • Cloud on AWS
    • VMware vRealize Suite Lifecycle Manager – 8.0
    • vRealize Log Insight
    • vRealize Network Insight
    • Hybrid Cloud Extension (HCX)
    • VMware Site Recovery Manager (SRM)
  • NSX
  • Nutanix
  • Power CLI
    • PowerCLI Snippets
  • VMware Horizon
  • Microsoft
    • Azure Cloud
      • Microsoft Azure Cloud and Services
      • Create Azure VMs ( PowerShell )
      • Create Azure VMs (Portal)
  • VOIP
  • Author
  • Contact

PowerCLI Error: “The underlying connection was closed: An unexpected error occurred on a send.”

Posted on June 4, 2020

Attempting to use VMware vSphere PowerCLI’s Connect-VIServer to a vCenter instance fails with error : “The underlying connection was closed: An unexpected error occurred on a send.”

So today I ma going to sharing solution with PowerCLI and Registry .

Nature of Problem

You have VMware vSphere PowerCLI version 5.1.0.4977 installed:

If I am using the Connect-VIServer cmdlet but it immediately fails with:

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Connect-VIServer vCenter.contoso.local

Connect-VIServer : 2/22/2019 11:41:37 AM Connect-VIServer The underlying connection was closed: An unexpected error

occurred on a send.

At line:1 char:1

+ Connect-VIServer vCenter.contoso.local

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

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

+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_WebException,VMware.VimAutomation.ViCore.Cmdl

ets.Commands.ConnectVIServer

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>


Solution with PowerCLI :

The reason why this error is thrown is because vCenter 6.7 only has TLS 1.2 enabled while TLS 1.0 and 1.1 is disabled by default so the older PowerCLI version installed, which attempts to connect via a one of the lower TLS versions will fail. The proper method of resolving this issue is to upgrade the old PowerCLI version to the latest one with the cmdlet Install-Module -Name VMware.PowerCLI

Another way type below command

#FORCE POWERCLI TO USE TLS1.2
=============================
PowerCLI E:\git> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Solution with Registry :

There are some registry key which you can create on the server to enable TLS 1.1 & TLS 1.2 so that communication can happen between PowerCli & vCenter server over TLS 1.2, below are the details –

For 32-bit processes, change the following registry key value to 1.

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework[.NET_version]
Value: SchUseStrongCrypto (DWORD)

For 64-bit processes, in addition to the above registry key, change the following registry key value to 1.

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework[.NET_version]
Value: SchUseStrongCrypto (DWORD)

Note: You must use PowerCLI 6.0 R1 or later. Earlier versions of PowerCLI work with versions of the .NET Framework that cannot use the TLSv1.1 and TLSv1.2 protocols by editing the registry.

The current version of Powercli can be checked by running “Get-PowerCLIVersion“.

Thanks hope you like it.

Rajiv Pandey. 

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to create Nutanix cluster

    How to create Nutanix cluster

  • How to Generate Data Store Utilization Report Cluster Wise by using Script

    How to Generate Data Store Utilization Report Cluster Wise by using Script

  • vSAN 7 – Native File Services

    vSAN 7 – Native File Services

  • VMware Cloud On AWS (PowerCLI )

    VMware Cloud On AWS (PowerCLI )

  • How to Upgrade VCF (VMware Cloud Foundation)  deployment from 3.5.1 to 3.7

    How to Upgrade VCF (VMware Cloud Foundation) deployment from 3.5.1 to 3.7

  • How to update VCF (VMware Cloud Foundation ) from 3.5 to 3.5.1

    How to update VCF (VMware Cloud Foundation ) from 3.5 to 3.5.1

  • PowerCLI Snippets Tutorial

    PowerCLI Snippets Tutorial

  • Generic vSphere Commands for Troubleshooting .

    Generic vSphere Commands for Troubleshooting .

  • Space reclamation of VMFS 5 Datastores by using esxcli

    Space reclamation of VMFS 5 Datastores by using esxcli

  • VMware vCenter Server Virtual Appliance (vCSA) 6.5 Backup process.

    VMware vCenter Server Virtual Appliance (vCSA) 6.5 Backup process.

Search Topic

©2021 | WordPress Theme by Superbthemes.com