11 Replies Latest reply on Jan 16, 2019 1:34 AM by xSyteck

    [CentOS 7][PowerCli] Cannot connect to ESXi

    xSyteck Novice

      Hello,

       

      I'm using PowerCli on a CentOS 7 VM, and I can't connect to some ESXi. There is actually only one that I can connect to, it's a sandbox, its version is 6.7.0.

      The others are on version 6.5.0, and are prod ones. I can ping every ESXiand they are accessible on port 443.

       

      PowerShell version:

      PS /root> $PSVersionTable

       

       

      Name                           Value

      ----                           -----

      PSVersion                      6.1.1

      PSEdition                      Core

      GitCommitId                    6.1.1

      OS                             Linux 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018

      Platform                       Unix

      PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}

      PSRemotingProtocolVersion      2.3

      SerializationVersion           1.1.0.1

      WSManStackVersion              3.0

       

      PowerCli version:

      PS /root> Get-Module VMWare.PowerCLI -ListAvailable

       

          Directory: /usr/local/share/powershell/Modules

       

      ModuleType Version    Name                                PSEdition ExportedCommands

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

      Manifest   11.1.0.... VMware.PowerCLI                     Desk

       

       

      This is what I get when I connect to the sandbox:

       

      PS /root> Connect-VIServer sandbox

       

       

      Specify Credential

      Please specify server credential

      User: userName

      Password for user userName: ***********

       

      Name                           Port  User

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

      sandbox                        443   userName

       

      And this what I get with production ones:

       

      PS /root> Connect-VIServer -Server productionServer [-Protocol https] [-Port 443]

       

      Specify Credential

      Please specify server credential

      User: userName

      Password for user userName: **********

       

      Connect-VIServer : An error occurred while sending the request.

      At line:1 char:1

      + Connect-VIServer -Server productionServer -Protocol https - ...

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

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

      + FullyQualifiedErrorId : System.ServiceModel.CommunicationException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

       

      I tried with different kind of options without success...

       

      On the other hand I can access those ESXi from my computer but not all, because of an intern policy that came up to avoid 443 port openning for no reason (web client use another port), this why I need to access ESXi with this VM.

       

      I can't do anything I want on those ESXi, I may not be able to access configuration or logs.

       

      Regards

        • 1. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
          LucD Guru
          User ModeratorsCommunity Warriors

          Did you already try over the port the Web Client is using?

          • 2. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
            xSyteck Novice

            When I try on the web port I get this error:

             

            Connect-VIServer : 1/11/19 10:44:49 AM  Connect-VIServer                Connection timed out

            At line:1 char:1

            + Connect-VIServer -Server serverName -Protocol https - ...

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

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

            + FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_SoapException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

             

            The fact is I asked for firewall rules creation, to allow this gateway to hit our ESXi on port 443 and it seems like there is no problem to get through this port:

             

            PS /root> nc -vz ypsvm001s.sys.meshcore.net 443

            Ncat: Version 7.50 ( https://nmap.org/ncat )

            Ncat: Connected to 10.35.222.13:443.

            Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

             

            I also tried different versions of PowerCLI but without more success...

            Someone in my company already built a gateway like the one I'm trying to set working, but he is not present until several weeks, we don't work in the same environment and we don't manage the same stakes. So I may being dealing with a problem he never got.

            • 3. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
              LucD Guru
              User ModeratorsCommunity Warriors

              Do you perhaps have a Windows station where you could try the same?

              With PowerShell 5.1 and PowerShell 6.*?

              They can be installed and used side-by-side.

              Just trying to figure out if the issue might be OS or PS version related?

              • 4. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                xSyteck Novice

                From my own computer, a Windows 7, from another network environment, with those version:

                 

                PS C:\WINDOWS\system32> $PSVersionTable

                 

                 

                Name                           Value                                                                                                                

                ----                           -----                                                                                                                

                PSVersion                      5.0.10586.117                                                                                                        

                PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                              

                BuildVersion                   10.0.10586.117                                                                                                       

                CLRVersion                     4.0.30319.42000                                                                                                      

                WSManStackVersion              3.0                                                                                                                  

                PSRemotingProtocolVersion      2.3                                                                                                                  

                SerializationVersion           1.1.0.1                                                                                                              

                 

                PS C:\WINDOWS\system32> Get-Module VMWare.PowerCLI -ListAvailable

                 

                    Directory: C:\Program Files\WindowsPowerShell\Modules

                 

                ModuleType Version    Name                                ExportedCommands                                                                          

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

                Manifest   11.1.0.... VMware.PowerCLI

                 

                It works (with or without stored credential):

                 

                PS C:\WINDOWS\system32> Connect-VIServer serverName           

                 

                Name                     Port  User                         

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

                serverName            443   userName

                • 5. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                  LucD Guru
                  User ModeratorsCommunity Warriors

                  Can you eventually install PS 6.1 on that Windows box.

                  It can be installed next to PS v5.*

                  I'm curious to know if the Connect-VIServer works in there.

                  • 6. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                    xSyteck Novice

                    Here we go for my Windows session:

                     

                    PS C:\Utilisateurs\userName> $PSVersionTable

                     

                    Name                           Value

                    ----                           -----

                    PSVersion                      6.1.0

                    PSEdition                      Core

                    GitCommitId                    6.1.0

                    OS                             Microsoft Windows 6.1.7601 S

                    Platform                       Win32NT

                    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}

                    PSRemotingProtocolVersion      2.3

                    SerializationVersion           1.1.0.1

                    WSManStackVersion              3.0

                     

                     

                    PS C:\Utilisateurs\userName> Get-Module VMWare* -ListAvailable

                     

                        Directory: C:\Program Files\PowerShell\Modules

                     

                    ModuleType Version    Name                                PSEdition ExportedCom

                                                                                        mands

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

                    Script     6.7.0.1... VMware.DeployAutomation             Desk      {Add-Dep...

                    Script     6.7.0.1... VMware.ImageBuilder                 Desk      {Add-Esx...

                    Manifest   11.1.0.... VMware.PowerCLI                     Desk

                    Script     6.7.0.1... VMware.Vim                          Desk

                    Script     11.0.0.... VMware.VimAutomation.Cis.Core       Desk      {Connect...

                    Script     11.0.0.... VMware.VimAutomation.Cloud          Desk      {Add-CID...

                    Script     11.0.0.... VMware.VimAutomation.Common         Desk

                    Script     11.0.0.... VMware.VimAutomation.Core           Desk      {Add-Pas...

                    Script     7.6.0.1... VMware.VimAutomation.HorizonView    Desk      {Connect...

                    Script     10.0.0.... VMware.VimAutomation.License        Desk      Get-Lice...

                    Script     11.0.0.... VMware.VimAutomation.Nsxt           Desk      {Connect...

                    Script     11.0.0.... VMware.VimAutomation.Sdk            Desk

                    Script     11.0.0.... VMware.VimAutomation.Security       Desk      {Get-Sec...

                    Script     11.1.0.... VMware.VimAutomation.Srm            Desk      {Connect...

                    Script     11.1.0.... VMware.VimAutomation.Storage        Desk      {Add-Key...

                    Script     1.3.0.0    VMware.VimAutomation.StorageUtility Desk      Update-V...

                    Script     11.0.0.... VMware.VimAutomation.Vds            Desk      {Add-VDS...

                    Script     11.0.0.... VMware.VimAutomation.Vmc            Desk      {Connect...

                    Script     10.0.0.... VMware.VimAutomation.vROps          Desk      {Connect...

                    Script     6.5.1.7... VMware.VumAutomation                Desk      {Add-Ent...

                     

                    PS C:\Utilisateurs\userName> Connect-VIServer serverName

                     

                    Specify Credential

                    Please specify server credential

                    User: userName

                    Password for user userName: ************

                     

                    Name                    Port  User

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

                    serverName           443   userName

                     

                    Doesn't seems like a PowerShell version issue, nor a PowerCLI version as I tried different version already.

                     

                    I don't think the OS is the problem, we already had one other VM like this one, I'll try to get its version of Centos 7.x, PowerShell package and PowerCLI module, in case of.

                    • 7. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                      LucD Guru
                      Community WarriorsUser Moderators

                      Could it be that the CentOS machine is not included in a FW rule?

                      • 8. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                        xSyteck Novice

                        At the beginning there was a deny all, because this VM is in a scope that is being handle individually. So I had to ask for FW rule change to open the port 443 to a dozen of ESXi.

                         

                        I used to see you in a lot of topics because I had a lot to learn and I had some issues while working with PowerCLI; this one is about the port used by PowerCLI I wondered if there was more than the port used by the command Connect-VIServer but you said that only 443 (or 80 I guess if we use http protocol) is needed.

                         

                        As you can see up there that netcat return that 443 port is open, is was a failure before I asked for FW change.

                         

                        The problem is the error information doesn't give me an tip about what is wrong...

                         

                        (Sorry if I write like a dumb, I'm french... The worst...)

                        • 9. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                          LucD Guru
                          User ModeratorsCommunity Warriors

                          No problem, I understand what you are saying.

                           

                          The 443 port is indeed correct, with the exception for cmdlets that use the VMware Tools, there you might also need port 902.
                          But indeed the Connect-VIServer should work with only port 443.

                          Unless you PSC is on a diffeferent box.
                          Do you know if that VCSA has an integrated PSC?

                          • 10. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                            xSyteck Novice

                            I looks like you could have the answer, we have external PSC and while using the webclient it ask a validation to those PSC (that should be accessible).

                             

                            I'm going to ask one FW change to see if it's the right issue, coming back later

                            • 11. Re: [CentOS 7][PowerCli] Cannot connect to ESXi
                              xSyteck Novice

                              Hello LucD,

                               

                              I come with great news: you were right, I asked for a firewall openning on the PSC of one VCSA and now I can connect to it !

                               

                              So for those who could have a generic error as

                               

                              Connect-VIServer : An error occurred while sending the request.

                              You may need to open the 443 port (by default) on both your ESXi and PSC if they're remote.