This script/Powershell functions can be used for (automatic) provisioning VM networks based on VLANs on existing Logical Network and switches in Virtual Machine Manager.
Create VM Network Function:
1. Check if VLAN already exist
2. Create Network site in logical network and add VLAN
3. Enable VLAN on Uplink Port Profile
4. Create VM Network
Remove VM Network Function:
1. Remove Logical Network Definition from Uplink Port Profile
2. Remove VM Network
3. Remove Logical Network Definition from Logical Network
Function CreateVMNetwork {
param($LogicalNetwork,$NetworkName,$VLANID,$VLANSubnet,$Hostgroup)
Download the script here