Virtual Network Management in Standard Switch Using Power CLI
This Post will help you to understand and create multiple port groups , Esxi host network details for complete environment .
Note : Below commands are used on vCenter with One host , it can be used multiple servers environment .
List vSwitch Inventory
Get-VirtualSwitch
List Portgroup Inventory
Get-VirtualPortGroup
Create a Virtual Switch
Get-VmHost | New-VirtualSwitch -Name “Test”
Create and add PortGroup to all ESXi hosts in cluster
Get-Cluster “clustername” | Get-VMHost | Get-VirtualSwitch -Name “vSwitch0” | New-VirtualPortGroup -Name “Portgrounp Name” -VLanId “XX”
Get VM host network details and output to the PowerCLI console:
Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask, Mac, PortGroupName, vMotionEnabled, mtu, FullDuplex, BitRatePerSec
Get VM host network details to CSV
Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask, Mac, PortGroupName, vMotionEnabled, mtu, FullDuplex, BitRatePerSec | Export-Csv C:\VMHostNetworkDetails.csv
Output
List of MAC addresses for all VMs on vcenter or Esxi and export to CSV
Get-View -Viewtype VirtualMachine -Property Name, Config.Hardware.Device |`Select name,@{n=”MAC(s)”; e={($_.Config.Hardware.Device |
?{($_ -is [VMware.Vim.VirtualEthernetCard])} | %{$_.MacAddress}) -join “,”}} | `Export-Csv c:\temp\VMMACsInfo.csv -UseCulture -NoTypeInformation
Note: You can directly use all commands in Power CLI or save file as Script with .PS1 extension run .
Output