Using PowerShell to Automate the Deployment of Veeam Agent for Microsoft Windows 2.0

Happy May Day everyone and well Happy 36th Birthday to me 😀

Now that the Veeam Agent for Microsoft Windows 2.0 is officially in its RTM build I am happy to share with the community some sample PowerShell that I have been working on. I’ll openly admit that I am not any where near a PowerShell or automation expert, in fact I very often to have to ask for assistance from friends or by Googling around for examples. With that automation is an intimidating and daunting task for most IT Professionals, but it does not have to be! My advice, is to take examples from around the community (like this example) and make it your own.

In this blog post I will provide you with everything that you need to be able to successfully automate the unattended deployment of the Veeam Agent for Microsoft Windows 2.0 by utilizing PowerShell.

Installation

In order to automate the installation we have to first have a known good configuration – to achieve this we’ll be utilizing the new configuration CLI / API tool that’s now available.

1.) Run the VAW setup on your server of choice – Next, Next, Next, Finish
2.) Apply your license
3.) Create your first VAW Backup

Next up, from an elevated command prompt cd to and run:

C:Program FilesVeeamEndpoint BackupVeeam.Agent.Configurator.exe  -Export

This will export your exact Agent configuration including the repository and all job settings to:

C:Program DataVeeamEndpoint!ConfigurationConfig.xml

With this we now have our exact ‘Gold Agent’ configuration within an XML document. Since the configuration is in the XML format the file can be easily updated or changed as necessary without having to export the configuration again.

PowerShell Automation

Windows and PowerShell go together like Peanut Butter & Jelly (BTW, I love me a good PB&J) – So for this we’ll be using PowerShell to automate the deployment of our Windows Agent along with the license file and configuration.

Lets take a look at how to get this done.

You can head to the VeeamHUB @GitHub to grab a copy of the sample script that I am providing here.

The PowerShell utilizes a file structure of:

.VAW2.0.0.677Source -> Source contains the .EXE
.VAW2.0.0.677Extras -> Extras contains the Config.XML and your .LIC file obtained

The PowerShell is broken up into 3 main areas:

1.) The first portion of the script performs the necessary checks and balancs to make sure that the directory structure is correct and in place.

$VeeamAgentInstallDirectory = $VeeamAgentInstallDirectory -Replace "\*$"
If ((Test-Path $LicenseFile) -eq $False) {
    Write-Host -ForegroundColor Red "Cannot find the License file at $LicenseFile"
    Exit 1
}
If ((Test-Path $ConfigFile) -eq $False) {
    Write-Host -ForegroundColor Red "Cannot find the Configuration file at $ConfigFile"
    Exit 2
}
If ((Test-Path $Installer) -eq $False) {
    Write-Host -ForegroundColor Red "Cannot find the Installer at $Installer"
    Exit 3
}

2.) The second portion actually installs Veeam Agent for Microsoft Windows. You will notice the /silent and /accepteula switches.  This script example allows for a completely unattended and silent installation of the product. The $Process checks every 2 seconds to see if the installation is completed and when safe the Process “Veeam.EndPoint.Tray” is stopped so that we can install our license key and configuration file.

Write-Host -ForegroundColor Green "Step #1: Installing Veeam Agent for Windows. Please wait a minute."
$Process = (Split-Path $Installer -leaf) -Replace ".exe$"
Start-Process -FilePath $Installer -Verb runas -ArgumentList "/silent /accepteula"
$counter = 0
Do {
    Start-Sleep -Seconds 2
    If ($counter % 10 -eq 0) {
        Write-Host -ForegroundColor Green "Waiting for installer to complete."
    }
    $counter++;
} While (Get-Process $Process -ErrorAction SilentlyContinue)

Stop-Process -Name "Veeam.EndPoint.Tray" -Force -ErrorAction SilentlyContinue

3.) The last portion of the script imports in the License File and Config.xml. You will need to run the License File import first as the Workstation and Server versions of the license file unlock additional capabilities like the Backup Cache, Cloud Connect Repository and Server Application Aware Image Processing.

Write-Host -ForegroundColor Green "Step #2: Applying your License File to the Protected Host"
Set-Location $VeeamAgentInstallDirectory
Start-Process Veeam.Agent.Configurator.exe -ArgumentList "-license /f:'$LicenseFile'"

Write-Host -ForegroundColor Green "Step #3: Applying your Desired Configuration to the Protected Host"
Start-Process Veeam.Agent.Configurator.exe -ArgumentList "-import /f:'$ConfigFile'"

Start-Process "$VeeamAgentInstallDirectoryVeeam.EndPoint.Tray.exe"

Summary

This sample PowerShell allows for an unattended installation process for the Veeam Agent for Microsoft Windows. In a future blog post via the official Veeam.com/Blog I will show you how you can take this to the next level and utilize Group Policy or System Center Configuration Manager (SCCM) to completely automate the deployment process.

************************************************************************************************************************

DISCLAIMER:

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4 thoughts on “Using PowerShell to Automate the Deployment of Veeam Agent for Microsoft Windows 2.0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: