Skip to content

Instantly share code, notes, and snippets.

@staybuzz
Last active June 1, 2018 17:57
Show Gist options
  • Save staybuzz/1dea20444018034b1e0e to your computer and use it in GitHub Desktop.
Save staybuzz/1dea20444018034b1e0e to your computer and use it in GitHub Desktop.
##################################
# Create Virtual Distributed PortGroup
# VLAN 20 - 160
20..160 | foreach {
Get-VDSwitch -Name "test" | New-VDPortgroup -Name ("VLAN{0:0}" -F $_) -NumPorts 15 -VLanId $_
}
# Create VM from Template
1...15 | foreach {
New-VM -Name ("T{0:0}mori_common" -F $_) -Datastore 'datastore1' -Template common-Template -ResourcePool Resources -DiskStorageFormat thin
}
# Set PortGroup to VM
Get-VM -Name T1mori_common | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName VLAN160 -RunAsync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment