I am looking to schedule a backup of all dvswitch from multiple vcenter servers. I am using below script, what else can be added here to to mitigate below points?
1) All vcenter should run from single schedule job
1) Output should have contained vCenter name in starting_portgroup name
2) Schedule the task for daily run at particular time
3) Send an email confirmation after completion
LucD - Your help required.
___________
$vcenter = “vc1", "vc2", "vc3"
$vcenteruser = “domain\user“
$vcenterpw = “password“
#
$date=get-date -uformat %Y-%m-%d
#
# End of script parameter section
#—————————————— #
#
# Connect to vCenter Server
connect-viserver $vcenter -User $vcenteruser -Password $vcenterpw
#
# Get the vNetwork Distributed switches
$switches=get-vdswitch
#
# Perform the backups
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 "c:\vSphere\$switch.without_portgroups.$date.zip"
#
# Backup each vNetwork Distributed Switch including the port groups
export-vdswitch $switch -Description "Backup of $switch with port groups" -Destination "c:\output\$switch.with_portgroups.$date.zip"
#
# Backup each port group individually
get-vdswitch $switch | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description "Backup of port group $($_.name)" -destination "c:\vSphere\$($_.name).portgroup.$date.zip"
}
}