PowerCLI: Set-dvSwitch
October 6, 2009 3 Comments
Last weekend I was playing around with the new dvSwitch feature in vSphere. So I created a dvSwitch and wanted to migrate my VM’s to it. Unfortunately this was not possible with the current version of PowerCLI. Normally you should be able to change the Network switch via:
Get-VM | Get-NetworkAdapter ` | Set-NetworkAdapter -NetworkName "traditional vswitch" -Confirm:$false
There must be a way to do this with PowerCLI but I didn’t know that way. So I asked Luc Dekens and the other PowerCLI guru’s for a solution. A couple of hours later Luc send me a script which was able to do exactly what I wanted to do.
The function / script can be found over here: http://poshcode.org/1373
You can start the function like this: Set-dvSwitch VirtualMachine dvSwitchPortgroup
Just wait a couple of seconds till the Reconfigure virtual machine task is ready:
You can also run this function against all your VM’s via the following command:
$vms = Get-VM foreach($vmName in $vms){ Set-dvSwitch $vmName dvPG_production }
Just wait a while and all your VM’s are migrated to the new dvSwitch:
If you want to start testing with the dvSwitch, keep an eye on http://lucd.info! @LucD22 is going to post an article about what you can do with PowerCLI and the dvSwitch.




Pingback: Twitter Trackbacks for PowerCLI: Set-dvSwitch « ICT-Freak.nl [ict-freak.nl] on Topsy.com
Pingback: vSphere 4.0 vNetwork Distributed Switch (vDS) - Video Demonstration + Architecture Diagram | The deep core of the phenomena| HyperViZor
Pingback: VMware vSphere - виртуализация ЦОД » Что такое и как работает vSphere 4.0 vSphere 4.0 vNetwork Distributed Switch (vDS).