## Considerations for Upgrading your Virtual Distributed Switch

The first consideration we would like to think about is why would I want to upgrade my VDS? Well if you had previously upgraded from vSphere 5.5 your VDS still may be on version 5.5 and this is not compatible with vSphere 6.7. Another reason is that we can review the new features that are listed below, we can see this when we click on the (i) within the VDS GUI. We can see that upgrading to version 6.0 gets us NIOC v3 and IGMP/MLD snooping, version 6.5 gives us port mirroring enhancements and version 6.6 gets us mac learning. If you run any nested virtualization in your environment this is a great enhancement as we no longer require you to enable promiscuous mode on your VM port group.

Get-VDSwitch "VDS"|Get-VMHost|Select Name, Version|Sort Name


We can see here that one of our hosts is not upgraded to 6.7 so if we were to proceed with upgrading our VDS it would fail. Before we proceed on to our next section we will make sure to upgrade our ESXi host to vSphere 6.7. If we were to attempt to upgrade our VDS prior to upgrading we would have encountered an error such as below.

Now that we are ready to move forward with upgrading our VDS, we will take some of the above considerations into place. Since we know if a vMotion is occurring during upgrade it will fail. We will make sure that if DRS is enabled we will put it into Partially Automated mode. Also, since we know we cannot rollback from a version upgrade we will make sure to take a backup prior to our upgrade. Unlike our previous blogs where we used simple one-liners, we will utilize a bit more logic in this upgrade that will be required as a script. As an introduction to the below script we will outline what it does. At the top we define variables for the VDS Name, Version we wish to upgrade to and the cluster(s) in which the VDS is attached. We will then check if DRS is enabled on the vSphere Cluster. If DRS is enabled we will store the current DRS Automation level and set it to Partially Automated, Backup the VDS, Upgrade the VDS and then we will restore the DRS Level back to the original state. If DRS is disabled, we perform a Backup of the VDS and then Upgrade the VDS. You can see the  code below and grab the script from GitHub.

Connect-VIServer "ds-vcsa-03.cpbu.lab" | Out-Null
$VDSwitch = "VDS"$VDVersion = "6.6.0"
$Cluster = Get-Cluster "Cluster" If ($Cluster.DrsEnabled -like "True") {
Write-Host "DRS is Enabled, it will be temporarily disabled during upgrade." -ForegroundColor "Green"
$ClusterDRSLevel =$Cluster.DrsAutomationLevel
Write-Host "DRS Cluster is currently set to $ClusterDRSLevel. Will change back when complete." -ForegroundColor "Green" Get-Cluster$Cluster | Set-Cluster -DrsAutomationLevel "PartiallyAutomated" -Confirm:$false Get-VDSwitch -Name$VDSwitch | Export-VDSwitch -Description "My Backup" -Destination "/PathToBackup/VDSBackup-$VDswitch-$((Get-Date).ToString(‘yyyy-MM-dd-hh-mm’)).zip"
Get-VDSwitch -Name $VDSwitch | Set-VDSwitch -Version$VDVersion
Write-Host "Upgrade is complete. Setting Cluster to $ClusterDRSLevel." -ForegroundColor "Green" Get-Cluster$Cluster | Set-Cluster -DrsAutomationLevel $ClusterDRSLevel -Confirm:$false
}
ElseIf ($Cluster.DrsEnabled -like "False") { Write-Host "DRS is Disabled, No additional action needed." -ForegroundColor "Green" Get-VDSwitch -Name$VDSwitch | Export-VDSwitch -Description "My Backup" -Destination "/PathToBackup/VDSBackup-$VDswitch-$((Get-Date).ToString(‘yyyy-MM-dd-hh-mm’)).zip"
Get-VDSwitch -Name $VDSwitch | Set-VDSwitch -Version$VDVersion
}


As we can see the upgrade is now complete. Even though the upgrade is itself a simple one-liner:

(Get-VDSwitch -Name $VDSwitch | Set-VDSwitch -Version$VDVersion)


We can automate the pre-requisites, backups and considerations to make this a more seamless upgrade.  If you are interested in understanding how you can upgrade your VDS through the UI please see my colleague Nigel Hickeys blog here.