Quantcast
Channel: VMware Communities : All Content - vSphere Upgrade & Install
Viewing all articles
Browse latest Browse all 3263

Migrate from a Virtual Distributed Switch to a Standard Switch using PowerCLI

$
0
0

I need to migrate vms on a host that uses a Virtual Distributed Switch to a newly created Standard Virtual Switch. I want to utilize the nics that the VDS is using for the new VSS.

 

The steps I want to accomplish:

  1. Create a new VSS
  2. Assign the VLANS that are associated with the VDS.
  3. Move the nics from the VDS to the VSS.
  4. Migrate the VMs to the new VSS.

 

I am trying to accomplish this with a script but I am not sure if this is written correctly. (See below)

 

Connect-VIServer vcenter -User XXX -Password XXX

 

# ESXi hosts to migrate from VSS->VDS

$vmhost_array = @("XXXX.com")

 

# Create VDS

$vds_name = "vSwitch2"

Write-Host "`nCreating new VDS" $vds_name

$vds = New-VDSwitch -Name $vds_name -Location (Get-Datacenter -Name "VDC")

 

# Create DVPortgroup

Write-Host "Creating new QA-LAB"

New-VDPortgroup -Name "QA-Lab" -Vds $vds | Out-Null

 

foreach ($vmhost in $vmhost_array) {

# Add ESXi host to VDS

Write-Host "Adding" $vmhost "to" $vds_name

$vds | Add-VDSwitchVMHost -VMHost $vmhost | Out-Null

 

# Migrate pNIC to VDS (vmnic11/vmnic7)

Write-Host "Adding vmnic11/vmnic7 to" $vds_name

$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic11

$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false

$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic7

$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false

 

# Migrate VMkernel interfaces to VDS

 

# dv QA-LAB #

$QALAB_portgroup = "dv QA-LAB"

Write-Host "Migrating" $QALAB_portgroup "to" $vds_name

$dvportgroup = Get-VDPortgroup -name $QALAB_portgroup -VDSwitch $vds

$vmpg = Get-VMHostNetworkAdapter -Name QA LAB -VMHost $vmhost

Set-VMHostNetworkAdapter -PortGroup $dvportgroup -VirtualNic $vmpg -confirm:$false | Out-Null

 

# Migrate remainder pNIC to VDS (vmnic7/vmnic11)

Write-Host "Adding vmnic11/vmnic7 to" $vds_name

$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic7

$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false

$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic11

$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false

 

}

 

<i><b>Disconnect-VIServer -Server $global:DefaultVIServers -Force -Confirm:$false

 

 

 

Any help would be appreciated. The ultimate goal will be to perform this then disconnect the host from the vcenter 4.1 and add it to the 5.0 vcenter.


Viewing all articles
Browse latest Browse all 3263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>