VMware Cloud Community
KrishnaBSR
Contributor
Contributor

Power cli script for ESXi host network configuration

Hi All,

How to capture the ESXi host network card hardware info, vSwitch, Port-groups and port groups policies by using power cli / power-shell scripts.

I have 5+ ESXi hosts  in my  data center.

I am using vSphere 5.5 .

Thanks in advance.

BSR Krishna

7 Replies
KrishnaBSR
Contributor
Contributor

Hi All,

I have 10 ESXI hosts in a vCenter with different ESXi clusters

Can I fetch the each ESXi host network configuration ( PNIC Info, Teaming Info, VLAN Info, Teaming Policies info)  thru power cli script,

Thanks

0 Kudos
LucD
Leadership
Leadership

Yes, that is possible.

There are many examples in this community, for example Re: vSwitch and Portgroup Security Settings

Did you try any of these ?

Is there any specific setting you are looking for ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
KrishnaBSR
Contributor
Contributor

Hi Lucd,

Thanks for quick response.

I am looking for ESXi host port groups / vlans configuration from power cli script.

Thanks & Regards,

BSR

0 Kudos
LucD
Leadership
Leadership

You mean the portgroupname and the VLAN ID like this ?

Get-VirtualPortGroup | Select Name,

@{N="VlanId";E={

      if($_.ExtensionData -is [VMware.Vim.DistributedVirtualPortgroup]){

        if($_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId -is [Array]){

          $_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId | %{

              $_.Start.ToString() + "-" + $_.End.ToString()

          }

        }

        elseif($_.ExtensionData.Config.DefaultPortConfig.Vlan.PvlanId){

          $_.ExtensionData.Config.DefaultPortConfig.Vlan.PvlanId

        }

        else{

          $_.ExtensionData.Config.DefaultPortConfig.Vlan.VlanId

        }

      }

      else{

        $_.VlanId

      }

}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
KrishnaBSR
Contributor
Contributor

Thanks a lot   Lucd.

i will check and update you .

Regards,

BSR

0 Kudos
KrishnaBSR
Contributor
Contributor

Hi Lucd,

This script works for vStandard switch  as well ?

Thanks & Regards,

BSR

0 Kudos
LucD
Leadership
Leadership

Yes, it should


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference