PowerShell Module for Veeam Availability Orchestrator

As a VMware Site Recovery Manager enthusiast I was very interested in the new Veeam Availability Orchestrator. And finally I found the time to deploy and configure the new rising start in the Veeam Software portfolio. Even in version 1.0 the Veeam Availability Orchestrator is already a great product and will help a lot of customers to create a reliable Disaster Recovery concept. During my configuration process I was wondering that there is no PowerShell Module for Veeam Availability Orchestrator available. But wait there is an API, so I started to create my own PowerShell Module.

Veeam has done a great job with the API Implementation. There is a great documentation and even a Swagger interface available.

PowerShell Module for Veeam Availability Orchestrator - Swagger

If you are interested in detail about installation and configuration of Veeam Availability Orchestrator I would recommend some great blog posts from my Veeam Vanguard fellows:

Creating a PowerShell Module for Veeam Availability Orchestrator

If a well-documented RESTFul API is available it is not very complex to get started with the right Tools. One of the most important Tools for me while working with RESTFul API is Postman.

Understand and verify the API calls

Before I start working on the PowerShell Module i try to understand the API and verify the calls i want to use in my PowerShell Module. Postman has also the capability to import Swagger File into a collection (Url: https://<VAO FQDN>:9899/swagger/docs/v1). After the Import only a few optimizations need to done:

  • Handle Authentication

Postman can run scripts after the API Call (tests). You can use these scripts to extract data from the response and write it to the Environment. These filled  variables can then be used in further API calls. In case of the Veeam Availablity Orchestrator API we need the tokens:

PowerShell Module for Veeam Availability Orchestrator - Postman test

  • Set variables

To be more flexible it is a common practice in postman to work with variables in call Url, Header and Body.

PowerShell Module for Veeam Availability Orchestrator - Postman Variables

I have exported my optimized Postman Collection into the GitHub Repository of the project.

Create PowerShell Module

Disclaimer:

What I am sharing here is just my practice to create a RESTFul API PowerShell Module and not the Best Practice to do this. There are way better modules available to show how to do is more efficient (e.g. VMware PowerNSX).

When I start building a RESTFul API based PowerShell Module I try to create two main initial functions, a function to connect to the API and another function as a helper for the general API calls. The connection function should also store the connection details, used by the general API call function. All further functions for application specific calls are based on the general API call function.

Connection function

Veeam Availability Orchestrator API authorization process is based on the OAuth 2.0 Authorization Framework.

More Details: Veeam Availability Orchestrator 1.0 RESTful API Reference – Authorization and Security

General API call function

The API call helper function uses per default the recommended headers for the Veeam Availability Orchestrator API endpoint. The header also includes the authentication token.

Application specific function

This is an example of a function included in the PowerShell Module for Veeam Availability Orchestrator based on the general API call function. In line 32 and 35 (depending on input) the general API call function is called.

PowerShell Module for Veeam Availability Orchestrator

New-VaoApiConnection

At first a connection to the Veeam Availability Orchestrator (VAO) instance needs to be established. The New-VaoApiConnection function authenticates with given credentials and saved the Authorization Token together with the environment details as a global variable for further use in other functions of the PowerShell Module for Veeam Availability Orchestrator.

The API can also refresh an existing token but this feature is not yet implemented.

PowerShell Module for Veeam Availability Orchestrator - New-VaoApiConnection

Documentation of the function: New-VaoApiConnection

Get-VaoSite

The Get-VaoSite function can be used to get a list of all registered VAO sites or to get a representation of a VAO site with the specified ID.

PowerShell Module for Veeam Availability Orchestrator - Get-VaoSite

Documentation of the function: Get-VaoSite

Properties:

PropertyTypeDescription
namestringName of a VAO site.
idstringSystem ID assigned to a VAO site in Veeam Availability Orchestrator RESTful API.
serverNamestringName of a machine on which a VAO site is registered.
contactNamestringContact name of a person responsible for monitoring VAO performance.
contactEmailstringEmail of a person responsible for monitoring VAO performance.
contactTelstringTelephone number of a person responsible for monitoring VAO performance.
descriptionstringDescription of a VAO site.
typestringType of a VAO site.
_linksdictionary of string [key] and object [value]Links to related resources (navigation property).

Source: https://helpcenter.veeam.com/docs/vao/restapi/sites_properties.html?ver=10

Get-VaoFailoverPlan

The Get-VaoFailoverPlan function can be used to get a list of all created failover plans or to get a list of all failover plans created for a VAO site with the specified ID.

PowerShell Module for Veeam Availability Orchestrator - Get-VaoFailoverPlan

Documentation of the function: Get-VaoFailoverPlan

Properties:

PropertyTypeDescription
namestringName of a failover plan.
idstringSystem ID assigned to a failover plan in Veeam Availability Orchestrator RESTful API.
contactNamestringContact name of a person responsible for monitoring VAO performance.
contactEmailstringContact email of a person responsible for monitoring VAO performance.
contactTelstringTelephone number of a person responsible for monitoring VAO performance.
descriptionstringDescription of a failover plan.
planStatestringCurrent state of a failover plan.
planStateDetailsstringProvides additional details on processing a failover plan and shows the number of errors and warnings occurred.
scheduleEnabledbooleanDefines whether a failover plan has a configured schedule.
scheduleTypestringDefines whether a failover plan will run at specific time (OnTime) or right after another plan (AfterPlan).
scheduleAfterstringSystem ID of a preceding failover plan.
scheduleAfterPlanNamestringName of a preceding failover plan.
scheduleTimestringDate and time when a failover plan will run.
siteIdstringSystem ID of a VAO site for which a failover plan is created.
_linksdictionary of string [key] and object [value]Links to related resources (navigation property).

Source: https://helpcenter.veeam.com/docs/vao/restapi/failoverplans_properties.html?ver=10

Set-VaoFailoverPlan

The Set-VaoFailoverPlan can be used, in the version 1.0 of the module, to enable or disable the given Failover Plan.

The API has a lot of more Operations and Methods for Failover Plans. Maybe some of them will be implemented in future versions of the PowerShell Module for Veeam Availability Orchestrator.

PowerShell Module for Veeam Availability Orchestrator - Set-VaoFailoverPlan

Documentation of the function: Set-VaoFailoverPlan

Get the Module

PowerShell Gallery  Read The Docs  GitHub

Did you like the article?

You can use this Amazon affiliate link to support the author of this article http://amzn.to/2pAgZOD

Leave a Reply