Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ?
- #Author: James Cruce
- #Date: 4/25/2017
- #Version: 0.1
- #Script has been modified to fit our environment
- #Original Script Source: http://vcdx56.com/2013/10/backup-vsphere-vnetwork-distributed-switches-using-powercli/
- # Script to backup the vNetwork Distributed Switches (VDS) including their port groups
- # The script will generate:
- # * 2 files per VDS, 1 including the VDS configuration without the port groups and 1 including the VDS configuration and the VDS port groups
- # * 1 file per VDS port group
- #
- # The script will run once a day meaning no need to use the force option to overwrite any existing backups since the date is included in the backup file names.
- #
- # Version 1.0 Magnus Andersson RTS
- #????????????????
- #
- # Start of script parameters section
- #
- # Connect to VIServer first
- $switches = $null
- $date = $null
- $date=get-date -uformat %Y-%m-%d
- #
- # End of script parameter section
- #?????????????? #
- # Get the vNetwork Distributed switches
- $switches=get-vdswitch
- #
- # Perform the backups
- foreach ($switch in $switches)
- {
- $DCName = $null
- $DCName = $switch.Datacenter
- # Backup each vNetwork Distributed Switch not including the port groups
- export-vdswitch $switch -Withoutportgroups -Description "Backup of $switch without port groups" -Destination "\\uncpath.yourdomain.local\Documentation\VMWare\Switches\$DCName\$switch.without_portgroups.$date.zip" -Force
- #
- # Backup each vNetwork Distributed Switch including the port groups
- Export-VDSwitch $switch -Description "Backup of $switch with port groups" -Destination "\\uncpath.yourdomain.local\Documentation\VMWare\Switches\$DCName\$switch.with_portgroups.$date.zip" -Force
- #
- # Backup each port group individually
- get-vdswitch $switch | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description "Backup of port group $($_.name)" -destination "\\uncpath.yourdomain.local\Documentation\VMWare\Switches\$DCName\$switch.$($_.name).portgroup.$date.zip" -Force
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement