Home > Blogs > VMware PowerCLI Blog

VDS Export/Import with PowerCLI

One of the great new features introduced in vSphere 5.1 was the ability to export and import the configuration of your vSphere Distributed Switch (VDS) and port groups to a file.

This gives you a quick restore method in case of issues or misconfigurations and also allows you to copy the entire VDS or port group configuration to a new VDS.  This feature is detailed by this VMware KB and is available via the vSphere Web Client, below you can see how we would do this via the web client:


Exporting the configuration with PowerCLI

With the introduction of the VDS cmdlets in PowerCLI 5.1 R2 we can also automate this process using the Export-VDSwitch and

Export-VDPortGroup cmdlets, the following examples show how we might do this:


We can also choose to backup each port group configuration individually, the following example shows how to do this for a single port group:


But what if we wanted to back up all our port groups for that VDS individually, we can easily achieve this with the following:


The code used for this example is as follows:

Get-VDSwitch -Name VDS-01 | Get-VDPortgroup | Foreach {
Export-VDPortGroup -VDPortGroup $_ -Description “Backup of $($_.Name) PG” -Destination “C:\Backups\$($_.Name).Zip”

Importing the configuration with PowerCLI

Now we have the exported configuration the next step is to look at how we could import these files again back into vCenter if an issue happened.  Of course each file could be imported from the vSphere web client individually but this post will show you how to do this with PowerCLI.


The code used in this example is as follows:

Get-ChildItem “C:\Backups\PG” | Foreach {
New-VDPortgroup -VDSwitch NewVDS -Name “New$($_.BaseName)” -BackupPath $_.FullName

As you can see from the below, we now have two DVS which have the same configuration:



Backing up the VDS and port group configuration can not only give you a backup in case of emergency but can also be useful for creating new switches with the same configuration, one use case for example is moving the VDS configuration between vCenters, like test & dev to Production.  The above examples show you how to automate this process with PowerCLI.

Don’t forget, the backup script could easily be scheduled to export on a weekly basis so that you have the latest configuration and multiple points in time to go back to.

Check out other new features in PowerCLI 5.1 R2 here

This entry was posted in Network, vCenter and tagged , , on by .
Alan Renouf

About Alan Renouf

Alan Renouf is a Product Line Manager at VMware focusing on API's, SDK's and CLI's, He is responsible for providing the architects and operators of private and public cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/PowerCLI a book author and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

9 thoughts on “VDS Export/Import with PowerCLI

  1. Pingback: You should backup your VDS Configs with PowerCLI « The Lowercase w

  2. Jason

    Can you tell me why when condensing the import into one line like this, would append the name.zip
    Get-ChildItem “C:\is\vDSBackup\” | Foreach {New-VDSwitch -Location (get-datacenter “mydc”) -Name “$_.BaseName” -BackupPath $_.FullName}

  3. Pingback: What does a Problem Solver do with a month away from clients? - Langton Blue Ltd

Leave a Reply

Your email address will not be published. Required fields are marked *