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.

13 thoughts on “VDS Export/Import with PowerCLI

  1. Rotem Agmon

    Hi Alan,

    Thanks for the write-up!

    I thought moving the VDS configuration between vCenters is not suppoted or does not work?

    Cannot use the vDS Import function to migrate to new vCenter Server (2045468)

  2. Alan Renouf

    Wow, that’s news to me, thanks for bringing that to my attention, hopefully this will be fixed in a future version.

    1. Alan Renouf

      Also after further reading of the KB article it looks like this is a specific configuration that does not work, in general it does work.

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

  4. Yasin AKILLI

    Thanks Alan,

    That’s totaly what I need.

  5. Easter Day Blessing 2016

    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.

  6. 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}

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

  8. shaan

    When i backup multiple dvswitches in same file, does the restore command restores all the dvSwitches

  9. poker online

    besar merupakan cikal bakal permainan poker saat ini, akan tetapi akhir-ahir ini para sejarahwan menentang bahwa poker merupakan turunan dari permainan as-nas, mereka lebih setujuh bahwa permainan lain merupakan induk dari permainan game poker

  10. interqq

    Media internet saat ini menjadi hiburan utama bagi masyarakat dunia terutama di Indonesia. Hiburan yang diberikan dari internet biasanya berbentuk game online

  11. sumoqq

    Beberapa jenis game ada yang dapat memberikan penghasilan kepada pemainnya, contohnya adalah poker online. Poker online

  12. dewaqq

    Poker online merupakan permainan yang menggunakan kartu remi dan sistem permainannya sama dengan permainan poker konvensional


Leave a Reply

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