PowerShell script exchange
Post Reply
emcclure
Influencer
Posts: 22
Liked: never
Joined: Oct 23, 2018 9:02 pm
Contact:

PowerShell/PowerCLI script to back up multiple VM's from vCenter one at a time

Post by emcclure »

Hello,

I'm new to the forum and new to running Veeam backup in PowerShell. I've written some PowerShell/PowerCLI scripts before to do some tasks, but never having to backup a VM to a location using Veeam. What I'd basically like to do is connect to a vCenter, get a list of VM's, perhaps from a specified VM folder, select the VM's to backup and then watch them backup one at a time. I feel something like this to get started would work:

Code: Select all

Get-Datacenter | select Name | Format-Table
$mydatacenter = Read-Host "Select a datacenter"
Get-Datacenter -Name $datacenter | Get-Folder -Type VM | sort Name | Format-Table
$myfolder = Read-Host "Choose a folder"
$vms = Get-Datacenter -Name $datacenter | Get-Folder -Name $myfolder -Type VM | Get-VM | sort Name | Out-GridView -OutputMode Multiple 
foreach ($vm in $vms)
{
Then at this point I'd like to incorporate Veeam to backup the VM's one at a time. But I don't know what to use here. We have Veeam Backup 9.5 and I'm running PowerShell 5.1 and PowerCLI 10.1 if that helps at all.

I was given a script (not sure where it came from) to look at and see if I could make it work this way, but I just don't know enough about it. I'm not sure how to put the code on here so it looks all pretty and is easier to read, so if someone can point that out for me that'd be great.

Thanks.
Talom
Enthusiast
Posts: 43
Liked: 6 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: PowerShell/PowerCLI script to back up multiple VM's from vCenter one at a time

Post by Talom »

Do you want to create a Backup Job for every single VM or do you want to start one Backup Job with all VMs in it?
For all VMs in one Backup Job you have to create and configure the Job and just add the Folder to it. Then start it and it will backup each VM in the Folder one at a time
BACKUP EAGLE® Developer
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: PowerShell/PowerCLI script to back up multiple VM's from vCenter one at a time

Post by veremin »

Also, let us know whether you're using free or paid VB&R edition; because script will vary, based on the answer. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests