Backup your Distributed Switch configs to a zip file.

This script will backup your Distributed Switch config to a zip file.
You can then use this zip file to restore the vDS to a new vcenter or if your vcenter database corrupts.

Add-PSSnapin VMware.VimAutomation.Core
Add-PSSnapin VMware.VimAutomation.Vds
Connect-VIServer “MyVcenter” -username “username” -pass “password”
$date= (get-date).tostring(‘ddMMMyyy-HHmm’)
$VDSwitches = get-VDSwitch | %{$}
foreach($vdswitch in $VDSwitches){
$filename = “E:\VDSBackup\”+$vdswitch +”-“+ $date+”.zip”
Get-VDSwitch -Name $vdswitch | Export-VDSwitch -Destination $filename

Disconnect-viserver -confirm:$False

View the Restore code here >

Vmware Link: