Use this when automating vSphere networking.
Networking
VMware networking automation creates standard and distributed switches, port groups and VLANs with PowerCLI (New-VDPortgroup) or Ansible, keeping host networking identical.
1. Network automation: VDS port groups, VLANs, VM adapters.
2. Consistent naming.
3. SoT-driven VLANs.
4. NSX via its API/Terraform.
5. Verify connectivity.
SoT → port groups → VM adapters
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as duplicate names, stale inventory, task still running after client timeout, vCenter/host permission gaps, storage/network dependency failure and assuming task success shows guest service health, choosing the cases most relevant to vSphere distributed/standard networking object identity, port groups/switches/adapters, VM attachment and reachability verification.
Step 2 Common mistakes Narrow the fault
- Port group names differing between hosts on standard switches.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Standard and distributed switches.
- Port groups and VLANs.
- Consistency across hosts.
Get-VDPortgroup | ft Name,VlanConfiguration— port groupsNew-VDPortgroup -VDSwitch <vds> -Name <n> -VlanId <id>— createGet-VM <vm> | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup <pg> -Confirm:$false— reconnect VM
ReferenceWhy it matters1 section · depth on demand
What it is
VMware networking automation manages vSwitches, distributed switches and port groups with PowerCLI or Terraform.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
VMware network automation manages port groups, distributed switches, VLANs and VM network adapters — and, with NSX, logical segments and firewall rules. Automating them keeps VLANs on the virtual side consistent with the physical network.
$vds = Get-VDSwitch -Name 'DSW-Prod'
New-VDPortgroup -VDSwitch $vds -Name 'PG-VLAN120-Guest' -VlanId 120
Get-VM app01 | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup 'PG-VLAN120-Guest' -Confirm:$false
- community.vmware.vmware_dvs_portgroup:
portgroup_name: PG-VLAN120-Guest
switch_name: DSW-Prod
vlan_id: 120
num_ports: 32
port_binding: static
state: present
Use a naming convention containing the VLAN ID, and generate port groups from the same source of truth that defines VLANs on the physical switches.
Example
Get-VDSwitch dvs01 | New-VDPortgroup -Name VLAN20 -VlanId 20
Get-VM web01 | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup VLAN20 -Confirm:$false
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in VMware Automation > Networking. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://developer.broadcom.com/powercli · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For vSphere distributed/standard networking object identity, port groups/switches/adapters, VM attachment and reachability verification, prefer typed fields and stable IDs over human presentation text.