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
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
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
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
regards,
O.Muntslag
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
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