#VMware VDS Backup PowerShell Script - backupvds.ps1
#Erik Hinderer
#ehinderer@vmware.com
#Version 0.2
param
(
[String] $ConfigurationFile = $(throw “Please specify the configuration file for the Content move.`r`nExample:`r`n`tGet-MachineLookup.ps1 -ConfigurationFile `”E:\Directory\ChangeThisPath.xml`””)
)
Import-Module VMware.VimAutomation.Vds
switch (Test-Path $ConfigurationFile)
{
True {Write-Host “Using $ConfigurationFile For Script Variables”
$Properties = [xml](Get-Content $ConfigurationFile)
}
False {Write-Host “$ConfigurationFile Not Found For Script Variables – Quitting”
Exit
}
}
$vCenters=$Properties.Configuration.Properties.vCenterList
$vCenterList = $vCenters.Split(“;”)
$BackupFolder = $Properties.Configuration.Properties.BackupFolder
foreach($vCenter in $vCenterList)
{
$date=get-date -uformat %d
$BackupPath=”$($BackupFolder)\$($Date)\$($vCenter)”
New-item -Type Directory -Path $BackupPath -force
connect-viserver $vcenter -force
$switches=get-vdswitch
foreach ($switch in $switches)
{
#
# Backup each vNetwork Distributed Switch not including the port groups
export-vdswitch $switch -Withoutportgroups -Description “Backup of $switch without port groups” -Destination “$($BackupPath)\$switch.without_portgroups.zip” -force
#
# Backup each vNetwork Distributed Switch including the port groups
export-vdswitch $switch -Description “Backup of $switch with port groups” -Destination “$($BackupPath)\$switch.with_portgroups.zip” -force
#
# Backup each port group individually
get-vdswitch $switch | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description “Backup of port group $($_.name)” -destination “$($BackupPath)\$($_.name).portgroup.zip” -force}
}
}