While working at different clients on their VMware infrastructure, I always gather complete inventory of a vCenter infrastructure first before doing any changes or designing a solution. This way I get to know very quick about the architecture. Here is my script which fetches all VDS (Virtual Distributed Switch) from logged in vCenter server. Base of the script is PowerCLI command Get-VDSwitch. All the information gathered can be easily saved to csv file.
Make sure you have installed VMware.PowerCLI module and using Connect-VIServer to connect to vCenter Server.
The inventory collected has information about VDS Name, Datacenter, Version, Numer Esx Hosts connected, ESXi Host Members, PortGroup Name, Number of Uplink Ports, Uplink PortGroup, Uplink Port Name, Number of Ports, MTU, Vendor, Contact Name, Contact Details, Link Discovery Protocol, Link Discovery Protocol Operation, vLan Configuration, Notes, Id, Folder, CreateTime, Health Check configuration, Over All Status, Multicast Filtering Mode, LACP api version, Network Resource Control version, vCenter server name.
To export information to CSV file use below command.
Get-VirtualDistributedSwitchInfo.ps1 | Export-Csv C:\Temp\vdsinfo.csv -NoTypeInformation
Download this script Get-VirtualDistributedSwitchInfo.ps1 here or it is also available on github.com.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
#Created By: vJanvi #WebSite: http://vcloud-lab.com #Purpose: Gather information of Virtual Distributed Switch (VDS) from vCenter using VMware PowerCLI $vdSwitch = Get-VDSwitch foreach ($vds in $vdSwitch) { $esxiList = @() $esxiServers = $vds.ExtensionData.Summary.HostMember if ($null -ne $esxiServers) { foreach ($esxi in $esxiServers) { $esxiList += Get-VMHost -Id $esxi | Select-Object -ExpandProperty Name } } <# $vdPortGroupList = @() $vdPortGroups = $vds.ExtensionData.Portgroup foreach ($vdportgroup in $vdPortGroups) { $vdPortGroupList += Get-VDPortgroup -Id $vdportgroup | Select-Object -ExpandProperty Name } #> $healthCheckConf1 = $vdSwitch.ExtensionData.Config.HealthCheckConfig[0] | ForEach-Object {"{0}: Enabled={1}, Interval={2}" -f $_.gettype().Name, $_.Enable, $_.Interval} $healthCheckConf2 = $vdSwitch.ExtensionData.Config.HealthCheckConfig[1] | ForEach-Object {"{0}: Enabled={1}, Interval={2}" -f $_.gettype().Name, $_.Enable, $_.Interval} [PSCustomObject]@{ Name = $vds.Name Datacenter = $vds.Datacenter Version = $vds.Version NumHosts = $vds.ExtensionData.Summary.NumHosts HostMembers = $esxiList -join ', ' PortGroupName = $vds.ExtensionData.Summary.PortgroupName -join ', ' NumUplinkPorts = $vds.NumUplinkPorts UplinkPortGroup = (Get-VDPortgroup -Id $vds.ExtensionData.Config.UplinkPortgroup).Name UplinkPortName = $vds.ExtensionData.Config.UplinkPortPolicy.UplinkPortName -join ', ' #VDPortGroups = $vdPortGroupList -join ', ' NumPorts = $vds.NumPorts Mtu = $vds.Mtu Vendor = $vds.Vendor ContactName = $vds.Contactname ContactDetails = $vds.ContactDetails LinkDiscoveryProtocol = $vds.LinkDiscoveryProtocol LinkDiscoveryProtocolOperation = $vds.LinkDiscoveryProtocolOperation VlanConfiguration = $vds.VlanConfiguration Notes = $vds.Notes Id = $vds.Id Folder = $vds.Folder CreateTime = $vds.ExtensionData.Config.CreateTime healthCheckConf1 = $healthCheckConf1 healthCheckConf2 = $healthCheckConf2 OverallStatus = $vds.ExtensionData.OverallStatus MulticastFilteringMode = $vds.ExtensionData.Config.MulticastFilteringMode LacpApiVersion = $vds.ExtensionData.Config.LacpApiVersion NetworkResourceControlVersion = $vds.ExtensionData.Config.NetworkResourceControlVersion vCenterServer = ([System.Uri]$vds.ExtensionData.Client.ServiceUrl).Host #$vds.Uid.Split('@')[1].Split(':')[0] } } |
Useful Information
Add NFS datastores to VMware ESXi hosts using PowerCLI
Using PowerCLI to Increase VMDK (Virtual disk) in VMware Virtual Machine
Add a VMFS datastore using VMware PowerCLI
POWERCLI: VMWARE ESXI CONFIGURE (VSWITCH) VMKERNEL NETWORK PORT FOR ISCSI STORAGE
POWERCLI VMWARE: CONFIGURE SOFTWARE ISCSI STORAGE ADAPTER AND ADD VMFS DATASTORE
POWERCLI: VIRTUAL MACHINE STORAGE MIGRATE/SVMOTION AND DATASTORE PORT BINDING MULTIPATHING
VMWare Powercli: Time Configuration (NTP - Network Time Protocol) on multiple Esxi server
vSphere PowerCLI - Configure syslog on VMware ESXi hosts and Enable security profile firewall
Part 1: VMware Powercli : Gather distributed virtual switch information to JSON file to migrate standard switch
Part 2: Copy or clone distributed virtual switch portgroups to standard switch portgroups - Powercli
Part 3: VMware Powercli: Migrate VMs to another network