Managing Virtual Switches and Networks Across Hyper-V Hosts Using Scripts

"Managing virtual switches should be done from a central point and the configuration should be automatically distributed to the host operating system in such a way as to eliminate the need for a separate configuration switches for each of the hosts." The requirement to "manage" is pretty generic, that could mean anything. Minimally we'd assume […]

"Managing virtual switches should be done from a central point and the configuration should be automatically distributed to the host operating system in such a way as to eliminate the need for a separate configuration switches for each of the hosts." The requirement to "manage" is pretty generic, that could mean anything. Minimally we'd assume it means create/update/delete virtual switches. System Center Virtual Machine Manager 2008 R2 GUI supports these operations but only on a host by host basis. So per host you can create, update, and delete virtual switches. Since this's VMM, anything you can do in the GUI you can do via PowerShell and extend. Scripts can be stored in the VMM library and executed from there.

Now when these run, you get presented with PowerShell shell that you can interact with if needed or just have script run without input. You can prompt for user input or get fancy with a menu system. There're multiple cmdlets that let you do things with virtual networks and switches like New-VirtualNetwork, Set-VirtualNetwork, Get-VirtualNetwork, Remove-VirtualNetwork. From VMM PowerShell console, you can do a get-help on these or see the reference document linked below.

More Info: [Cmdlet Reference – SCVMM 2008 R2 | Failover Cluster] | Hyper-V PowerShell Library on CodePlex | Script