VMware Cloud Community
omunt
Contributor
Contributor
Jump to solution

migrate vm network cards from DVS to standardswitch and back

Hi,

Does anyone know how to change a vm's nics that are connected to a DVS to a standard portgroup. (POWERCLI)

The portgroups on de standard switch have the same names as the ones on de DVS.

If possible, is it possible toe switch back from standard switch to dvs ?

We need this for a online migration of vm's between two different ESX 55 environments.

Thanks

O.Muntslag

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

To save the portgroup in a variable for a standard switch, you can use a command similar to the following PowerCLI command:

$PortGroup = Get-VirtualPortGroup -Name NetworkName -Virtualswitch vSwitch1 -VMHost ESXi1

To save the portgroup in a variable for a distributed switch, you can use a command similar to the following PowerCLI command:

$PortGroup = Get-VDPortgroup -Name NetworkName -VDSwitch dvSwitch0

Using the $PortGroup variable you can modify a vm's nic portgroup with a command similar to:

Get-VM -Name VM1 | Get-NetworkAdapter -Name 'Network adapter 1' | Set-NetworkAdapter -Portgroup $PortGroup -Confirm:$false

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
4 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

To save the portgroup in a variable for a standard switch, you can use a command similar to the following PowerCLI command:

$PortGroup = Get-VirtualPortGroup -Name NetworkName -Virtualswitch vSwitch1 -VMHost ESXi1

To save the portgroup in a variable for a distributed switch, you can use a command similar to the following PowerCLI command:

$PortGroup = Get-VDPortgroup -Name NetworkName -VDSwitch dvSwitch0

Using the $PortGroup variable you can modify a vm's nic portgroup with a command similar to:

Get-VM -Name VM1 | Get-NetworkAdapter -Name 'Network adapter 1' | Set-NetworkAdapter -Portgroup $PortGroup -Confirm:$false

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
omunt
Contributor
Contributor
Jump to solution

thanks !! this works great for switching from STD to DVS.

Do you know how to switch back ?

i would like to use a input file with a couple of vm's and be able to switch from std to dvs or from dvs to std Smiley Happy

regards,

O.Muntslag

0 Kudos
omunt
Contributor
Contributor
Jump to solution

no i created this :

$vmlist = get-vmhost esx04.pimdomain | get-vm

foreach($vm in $vmlist){

    Get-NetworkAdapter $vm | %{

    Write-Host "Setting adapter" $_.NetworkName on $vm

    $_ | Set-NetworkAdapter -PortGroup (Get-VDPortGroup -Name $_.NetworkName -VDSwitch dvSwitchHP) -Confirm:$false

}

}

i need to know how to switch back from dvs to std Smiley Happy

0 Kudos
omunt
Contributor
Contributor
Jump to solution

got it :

$vmlist = get-vmhost esx04.pimdomain | get-vm

foreach($vm in $vmlist){

    Get-NetworkAdapter $vm | %{

    Write-Host "Setting adapter" $_.NetworkName on $vm

    $_ | Set-NetworkAdapter -PortGroup (Get-VirtualPortGroup -VMhost esx04.pimdomain -Standard -Name $_.NetworkName) -Confirm:$false

}

}

thanks for the help

0 Kudos