5 Replies Latest reply on Jan 21, 2013 12:17 PM by johndavidd

    get amount of uplinks on distributed switch

    RobMokkink Expert

      I am looking for a way to determine the amount of uplinks connected to a distributed switch.

       

      It this possible through a cmdlet or SDK. I have looked bt can't find it.

        • 1. Re: get amount of uplinks on distributed switch
          firestartah Master
          vExpertCommunity Warriors

           

          You can see it via the console but guessing by you asking the powershell cmdlet you don;t have or don;t want to do it this way so

           

           

           

          Get-dvSwUplink should work.

           

           

          If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".

           

           

           

          Gregg Robertson, VCP3,4 , MCSE, MCSA, MCTS, MCITP

           

           

          • 2. Re: get amount of uplinks on distributed switch
            LucD Guru
            Community WarriorsvExpertUser Moderators

            The following function just gives the names of the uplinks of a specific dvSwitch.

            I had this function in my toolbox but didn't consider it worth a separate post.

             

            You use it together with my Get-dvSwitch function I posted in dvSwitch scripting – Part 2 – dvPortgroup.

             

            function Get-dvSwUplinks{
             param([parameter(Mandatory = $true, ValueFromPipeline = $true)]
             [http://VMware.Vim.VmwareDistributedVirtualSwitch|http://VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw)
             
                 Process{
                      $dvSw.Config.UplinkPortPolicy.UplinkPortName | %{
                           New-Object PSObject -Property @{
                                UplinkName = $_
                           }
                      }
                 }
            }
            

             

            You use it like this

            Get-dvSwitch "DC1" "dvSw1" | Get-dvSwUplinks
            

             

            And it will return this

            UplinkName
            ----------
            dvUplink1
            dvUplink2
            dvUplink3
            dvUplink4
            

             

            If you only need the amount of Uplinks you can do

            (Get-dvSwitch "DC1" "dvSw1" | Get-dvSwUplinks).Count
            

             

            I was thinking of expanding this function with other properties like Port ID, Connectee, Portgroup...

            In short what you see in the vSphere client.

            Is there anything specific you want to see returned by the function ?

             

             

            ____________

            Blog: LucD notes

            Twitter: lucd22

            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 3. Re: get amount of uplinks on distributed switch
              RobMokkink Expert

               

              Hi Luc,

               

               

               

               

               

              That was exactly what i was looking for. I missed that part on your website.

               

               

               

               

               

              • 4. Re: get amount of uplinks on distributed switch
                LucD Guru
                Community WarriorsvExpertUser Moderators

                It's not (yet) on my website.

                 

                I was thinking of other uplink properties to return.

                I'll think I go for all the properties that are visible in the vSphere client.

                 

                 

                 

                 

                ____________

                Blog: LucD notes

                Twitter: lucd22

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: get amount of uplinks on distributed switch
                  johndavidd Enthusiast

                  LucD .... Did you ever finish this function and add all the properties in? I'm looking for it to return the port ID and connectee you see in the vSphere Client.