Use this when creating Hyper-V virtual switches by script.
Virtual Switches
Hyper-V virtual switch automation creates external, internal and private switches with New-VMSwitch, including Switch Embedded Teaming, and sets VLANs with Set-VMNetworkAdapterVlan.
1. Virtual switch automation: consistent names across hosts, SET teams, VLANs.
2. Creating external switches can interrupt host networking — use console/OOB.
3. Script per host consistently.
4. Validate.
5. Document.
switch definition → hosts → 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 Common mistakes Narrow the fault
- Creating an external switch on the management NIC and losing connectivity.
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.
- External, internal or private.
- SET teams NICs.
- VLANs set per adapter.
Get-VMSwitch— switchesNew-VMSwitch -Name <n> -NetAdapterName <nic1>,<nic2> -EnableEmbeddedTeaming $true— SET switchSet-VMNetworkAdapterVlan -VMName <vm> -Access -VlanId <id>— VLAN
ReferenceWhy it matters1 section · depth on demand
What it is
Virtual switches connect VMs to networks: External, Internal or Private.
ReferenceImportant terms & boundaries2 sections · depth on demand
How it works
A Hyper-V virtual switch is a software Layer 2 switch in the host. External switches bind to a physical NIC (optionally shared with the host), Internal switches connect VMs and host only, Private switches connect VMs only. VLAN tagging is set per VM network adapter.
Example
New-VMSwitch -Name vSwitch-LAN -NetAdapterName 'Ethernet 2' -AllowManagementOS $false
Set-VMNetworkAdapterVlan -VMName web01 -Access -VlanId 20
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 Hyper-V Automation > Virtual Switches. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/powershell/module/hyper-v/?view=windowsserver2025-ps · confidence 94%