«

»

Oct 29 2013

Backup vSphere vNetwork Distributed Switches using PowerCLI

A few weeks ago a customer asked me how to automate the export of the vSphere vNetwork Distributed Switches (VDS) configuration. Their existing routine included to make a manual export of the VDS configuration whenever a VDS change was implemented including adding or removing a VDS port group.
In the vSphere Web Client you can easily export the configuration per VDS by right-click the VDS and select “All vCenter Actions” and “Export Configuration”
Screen Shot 2013-10-29 at 20.58.51

When performing a VDS backup you can select if you want to include the VDS port groups or not.
Screen Shot 2013-10-29 at 21.07.11

There is also an option to perform a configuration export of an individual VDS port group by right-click the VDS port group and select “All vCenter Actions” and “Export Configuration”.

Below you’ll find the PowerCLI script i implemented in my customers environment that is running vSphere 5.5.

Change the following parameters in the below script to match your environment:

  • $vcenter = “vc01.vcdx56.local“
  • $vcenteruser = “vcdx56\magnus“
  • $vcenterpw = “not secret“
  • Backup each vNetwork Distributed Switch not including the port groups directory = c:\vSphere\$switch.without_portgroups.$date.zip”
  • Backup each vNetwork Distributed Switch including the port groups directory = “c:\vSphere\$switch.with_portgroups.$date.zip”
  • Backup each port group individually directory = “c:\vSphere\$($_.name).portgroup.$date.zip”

Change the red marked text in the script to your required values.

To schedule the PowerCLI script on a Windows machine, see my Schedule PowerCLI script in Wndows task scheduler blog post.

To restore the VDS you right-click the VDS and select “All vCenter Actions” and “Restore Configuration”.
Screen Shot 2013-10-29 at 21.20.43

When performing a VDS restore you got two options, same as when exporting the VDS configuration, either restore the VDS with the port groups included or not.
Screen Shot 2013-10-29 at 21.20.58

Restore the VDS port group by right-click the VDS port group and select “All vCenter Actions” and “Restore Configuration”.

You can also use PowerCLI to restore the VDS and the VDS port group if you want.

1 comment

  1. Steve Schofield

    Here is an updated script.
    Automate backing up DVS using Powercli and POwerShell

    http://iislogs.com/steveschofield/2015/09/08/automate-backing-up-dvs-using-powercli-and-powershell/

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">