Automate Veeam Restores Using PowerShell


One of the powerful things that Veeam offers is the ability to use PowerShell to both backup and restore virtual machines.  This makes for great ways to automate tasks either backups or restores, or even other jobs via the PowerShell hooks into Veeam Backup & Replication.  In this post we will look at how to automate Veeam Restores Using PowerShell as it provides an extremely streamlined and much more efficient manner of restoring bulk virtual machines as opposed to the GUI interface.

vbrposh01 Automate Veeam Restores Using PowerShell

Automate Veeam Restores Using PowerShell

Ok, so let’s take a look at the code to see how we can automate restores using the PowerShell module for Veeam.  This is extremely handy especially if you are using Veeam to restore bulk virtual machines into a lab environment from production.

The first bit of code we will set some variables here to work with during the restore of the virtual machines.  We will use a text file to read the list of servers that we wish to restore in the lab environment.  In the following lines for vcentersuffixesxihost, populate information specific to your environment.  One variable I had issues with in the Veeam PowerShell commandlets was figuring out how to correctly populate the resourcepool information.  Using only the Find-VBRViEntity commandlet without scoping it always resulted in a $null value being returned for resourcepool.

A workaround for that issue was to run the command Find-VBRResourcePool -Server <your esxihost> and using the Reference returned in that command to scope our command below.  Populate your datastorefolder, and logfile with your information.

Next, a function to do some logging for us (this function is used in other community sourced github PowerShell code:

Next, is our for loop for actually doing the restoration work.  Note how easy with the Start-VBRRestoreVM command it is to define the folderdisktype, and skiptagsrestore options.  Especially with the disktype, if you are restoring several servers that have multiple disks and you want to select thin as the disk type, you have to in the GUI click every single one and choose thin.  There is not an option in the GUI to multiselect for the disk type.  Notice as well using the RunAsync parameter allows the jobs to all be kicked off by the Powershell commandlet.  If you don’t have this option included, it will kick off the first server, wait until it is fully restored, and then kick off the next server, etc.  This will take much longer than simply kicking them off asynchronously which allows the script to schedule the restores and complete.

Now, lets look at the code all together.


The ability to Automate Veeam Restores Using PowerShell is a powerful way to quickly and much more efficiently kick off restores using the Veeam PowerShell commandlets.  Especially with mundane tasks that require “point and click” type work, using PowerShell is way better and saves a lot of heavy lifting with these kinds of tasks.  If you are using Veeam in your environment, be sure to take advantage of using PowerShell.