Getting started with Veeam for PowerShell

Shame on me! Right after VeeamOn 2018, life threw my family some major league curve-balls and I never had a chance to get my code shared out. Time to fix that…

For those of you who may be coming at this fresh, Veeam has provided a PowerShell SnapIn for configuring, maintaining and monitoring Backup and Replication. Simply choose to install the Veeam Backup and Recovery console from the B&R ..iso file or follow the instructions in this KB article. When you launch the Backup and Replication console, you’ll find a PowerShell menu option under the main Console menu. The way I write, I really need an ISE and as built you just get a PoSH window, rather than ISE. So I did a little sleuthing… and I mean little. I typed the command Get-History and low and behold, the VBR shortcut fires off a PowerShell script located at:

“C:\Program Files\Veeam\Backup and Replication\Console\Install-VeeamToolkit.ps1”

It’s always an interesting read to see how other people solve problems. Basically the script does a bunch of validation and calls another script C:\Program Files\Veeam\Backup and Replication\Console\Initialize-VeeamToolkit.ps1  more validation, aliases, options etc and finally we see two things:

  • The script functionality is delivered by VeeamPSSnapIn
  • The functions Get-VBRCommand and Get-VBRToolkitDocumentation are defined in the Initialize-VeeamToolkit.ps1 script. You’ll need another path if you want to make use of them, but I’m gonna help you out there in a minute.

TLDR: Add-PSSnapin VeeamPSSnapIn

Above I mentioned Get-VBRToolkitDocumentation.  Interestinglyl this function fires up the Veeam documentation at https://helpcenter.veeam.com/docs/backup/powershell/

It’s a pretty good and comprehensive document set, so I’d highly recommend checking it out. Seriously, it’s a really good guide with some great examples that I’d encourage you to explore.

Get-VBRCommand

This is an interesting one. It basically uses the Get-Command to list out all of the VBR commands. If you drill into an individual command you get some more info about what’s under the cover, but what’s really interesting to me is if you take a peek at some of the numbers coming out of this function. As of this writing, there are

  • 510 individual cmdlets in the Veeam Backup and Replication SnapIn,
  • 27 Verbs
  • 259 Nouns

If you’re like me, that’s a pretty intimidating sample to tackle. But if you look at the data slightly differently, it gets much more manageable.

Starting with the Verbs, we see that 1/5 of the cmdlets are get’s and when you combine that with Set and Add over half of all the cmdlets from this snappin are accounted for.

veeam backup and replication powershell toolkit

Now when you turn to look at Nouns, the data is very different.

veeam backup and replication powershell toolkit2

Wow… Verbs are consolidated, however nouns are numerous. This is odd at first glance, but when you think about it, it totally makes sense. The Veeam B&R snappins are meant to support a variety storage/backup/infrastructure products, but the actions you can perform across these products are more or less consistent. This consistency is great for you as you get started on your way towards automating your infrastucture with PowerShell. We’ll start going deeper into that infrastructure management in our next post, stay tuned!

Leave a comment