Opvizor

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

Rajesh Radhakrishnan

Share
Published by
Rajesh Radhakrishnan

Recent Posts

NAKIVO Backup & Replication v10.8 Released With New Features

Nakivo has released its new Backup and Replication solution Nakivo v10.8, which includes support for…

1 year ago

Oracle Cloud VMware Solution and Features

Oracle Cloud VMware Solution (OCVS) provides a customer-managed, native VMware-based cloud environment hosted in Oracle…

2 years ago

Vinchin Backup and Recovery Review

Vinchin is a professional provider of data protection solutions for enterprises. It provides a series…

2 years ago

VMware Cloud Disaster Recovery (VCDR) Solution Deployment And Configuration Part 2

In my previous blog post, I have explained about VMware Cloud Disaster Recovery (VCDR) Onboarding and…

2 years ago

How to Deploy vRNI Cloud With VMC on AWS

vRealize Network Insight helps you build an optimized, highly available, and secure network infrastructure across…

2 years ago

This SysAdmin Day, WIN with Hornetsecurity!

Can you believe it's here again? SysAdmin Day is back, and with it comes endless gratitude…

2 years ago