PowerShell to Upgrade the Virtual Distributed Switch (VDS)

After upgrading vSphere to version 7 there is one more component needs to be upgraded. VMware Virtual Distributed Switch (VDS).

NOTE: Prior VDS upgrade all ESXi hosts MUST be upgraded. Otherwise upgrade will fail.

NOTE: The VDS upgrade has no rollback, once it is complete it is permanent unless you have completed a backup.

NOTE: If a vMotion occurs during the upgrade the VDS upgrade will fail.

Let’s start by creating back up script:

  1. Lets find a VDS which needs to be upgraded. (As I already have a few on 7.0.2 version, I need to upgrade only which are still on 6.5.0 version)
$oldversion = Get-VDSwitch | where version -Like "6.5.0"
  1. Let’s back up our VDS
Get-VDSwitch -Name $oldversion | Foreach {
Export-VDSwitch -VDSwitch $_ -Description "Backup of $($_.Name) VDS" -Destination "c:\temp$($_.Name).zip" -Force
} 

$_ is variable in pipeline, you can treat it as shortcut.

-Force is here to override any existing .zip archive

I hope the code is easy to understand, but if you have any question, please leave a comment.

Once we have our back up done, lets upgrade our VDS:

  1. Let’s add new variable for our VDS version:
$newversion = "7.0.2"
  1. Lets upgrade:
$oldversion | Set-VDSwitch -Version $newversion

Whole code:

$oldversion = Get-VDSwitch | where version -Like "6.5.0"
$newversion = "7.0.2"
$oldversion | Set-VDSwitch -Version $newversion



Step-by-step video:

Please like and share to spread the knowledge in the community.

Visit my FB page: https://www.facebook.com/AngrySysOps

Subscribe to my YouTube channel: https://www.youtube.com/channel/UCRTcKGl0neismSRpDMK_M4A

Let’s chat on Twitter: https://twitter.com/AngrySysOps

Please leave the comment