Why do we vCommunity?

I went out for a lunch walk the other day to clear my head and listened to a really great episode of Freakonomics. The episode Honey I grew the economy focused on the process and motivators that drive innovation. The deep dive into drivers in particular resonated a lot with me. I saw parallels to how we approach IT as we kick off 2020. While that was super interesting, it wasn’t a giant leap for me to ask a similar question of:

Why do we get engaged in the various technological communities and what do we derive from those communities?

This seemed like a fun opportunity to hear from some of our Technology Community members to understand: Why do we vCommunity?

To Learn

For me, first and foremost, vCommunity is about Education. It stands to reason that it’s the most common entry point for people to engage. It makes sense: You need help on a topic, so you go looking around and only then do you learn about the plethora of opportunity’s available to you. When I personally started down the virtualization path, training dollars were tight, so to improve my knowledge I had to look elsewhere and as luck would have it, I found the Boston VMUG UserCon. That free one day training, gave me access to educational presentations, subject matter experts and hands on training. It was a formative moment for me, and opened my eyes to other avenues of learning. It also showed me that there were a ton of engaged people out there sharing via different mediums.

Stalwart of the vCommunity, Kyle Ruddy had something similar to share regarding his introduction to the tech communities “What I wasn’t ready for was the amount of blogs out there detailing issues I had run into. It was a complete lightbulb moment. From that point it was a gradual process of moving from reading blogs to creating blogs.”

Kyle also highlights a hallmark of the community in that there tends to be a strong desire to contribute back in the form of blogs, videos, podcasts and a host of other mediums. That was after all the genesis for VirtualVT as well. If you look at the mechanics of sharing content, it takes time and effort. You can’t help but boost your knowledge whenever you’re contributing technical content, because you end up spending more time with the underlying technology’s.  Unintentional education? Knowledge Osmosis? Whatever you call it, the brain gets bigger the more you feed it, and you have to keep feeding if you’re creating content about technologies.

To Grow

Bolstering your knowledge via the educational opportunities the communities provide is definitely a path to bigger and better things, but I’ll let you in on a not-so-secret, secret. Getting involved and putting yourself out there as a contributing member of the community can be equally impactful on your career. Contributing is an idealistic endeavor, but it often has the side effect of building your brand at the same time. I met the MVP power couple of Dave and Cristal Kawula this past fall and in a recent blog post Dave shares a bit about how he and Cristal started MVPDays and the impact their event has had on a specific community member: “…I talked him into doing his first presentation, which led to him speaking at user groups and conferences. Earlier this year he became a Microsoft MVP, and a few days ago, he actually accepted a position at Microsoft.

The experience that Dave highlights is not unique to MVPDays. It crosses groups and goes to the heart of what Matt Heldstab (VMUG Board of Directors) shared with me recently “The fantastic power of this vCommunity and its ability to elevate the careers of its members never ceases to amaze me.

It’s Fun!

vDodgeBall, vSoccer, vPoker are just a few of the side-events that come to mind for ways that we like to enjoy the lighter side of our geekdom. One of my favorite events was when our 2017 vExpert party was held at the Pinball Museum in Las Vegas. The reality is that many of us work really hard and through a plethora of events, engagement in the vCommunity can be a nice way to blow off some steam. My friend AJ Murry who I co-led a local VMUG group with, hits on this point “In the vCommunity I have found my people. I have made life long friends. I have learned great things and shared amazing experiences.

It’s all about the people

2019-12-31 14_09_51-Community _ Definition of Community by Merriam-WebsterI mean it’s referred to as the vCommunity for a reason! The one theme that comes up time and time again when talking about our tech communities, was the value of our peer connections. We learn, share and when times are tough, we support each other. Nikola Pejkova, Veeam Vanguard Community Mangager highlights the value of these connections: “I love being part of community because it enables its members cooperate together, strengthen and enrich their knowledge and learn from each others experiences.

Everywhere I’ve gone and nearly everyone I’ve interacted with has been gracious with their knowledge and time. It’s a hallmark of these communities and a reason why there are so many deep bonds. You see it in every independent blog post, every community presentation and every response to a forum post. That’s the real magic to the vCommunity: We want to be there for each other and to collective lift each other up!

So how do YOU get involved?

It’s an amazing thing being part of this community, but like many things in this world, it can be intimated to get started, so what can YOU do?

Well there’s no time like the present. There are user communities abound. Listen, I live in a rural state where my favorite urban legend says that there are more cows than people. If I can find a local community, so can you! Find one (meetup can be an excellent starting point) and go, even if it’s not in your wheelhouse. Especially if it’s not in your wheelhouse! Go learn something new, meet some interesting people and hopefully have a good time!

Got something worthwhile to share? A blog is stupid easy to create these days. I wouldn’t be here if it wasn’t! Only a year or two, it was really hard to podcast or create video equipment, as the equipment required was cost prohibitive to most. As we kick off 2020, there’s no reason not to share it loud a proud! And if creating online content isn’t enough for you, there are always conference CFPs (calls for papers) that are looking for passionate people to share their successes.

All of these options strike fear into your heart, but you’d still like to help others? Online opportunities are abound as well. Helping someone solve a problem or answer a question in a forum, benefits not just you and poster, but future assistance seekers as well.

Whatever the avenue, just do it! If you’re still not convinced, I’d like to give Kyle the last word on why we vCommunity. “Now, why do I continue to be involved… over the years, I’ve found it extremely rewarding to share my experiences and knowledge, become a mentor, [and] … build up a number of friendships that exist still to this day.”

Thank you to my friends quoted here and to all my friends out and about in the communities for all that you do.

Getting started with Veeam Backups for Microsoft Office 365

The topic of data protection for cloud services seems to surfacing a lot lately. I’ve had a debate with myself as to whether this is akin to when you buy a car, all of a sudden you notice just how many of your car are on the road OR as we’re approaching 2020 is everyone coming to the realization that even in the cloud you need to protect your assets and that not everything can be ephemeral.

The premise of the conversation is that with Cloud, you push off ownership of the infrastructure/platform. But what about the data? Who is responsible for making sure that it’s protected? It’s a good fundamental question that there is a lot of FUD around. But cutting straight to the chase, it’s your responsibility to ensure that your data is protected. AWS alludes to this with their shared security model, but other cloud providers bury this fact in their T’s & C’s. Gartner has a good whitepaper (behind paywall, so not linked here) laying out that YOU are responsible for YOUR data, so you can’t presume that your Cloud provider is protecting it for you

With this in mind, it seemed like an opportune time to look at how we’re protecting our Office 365 assets. What I’d like to cover today is a brief exploration of the Veeam Backup for Microsoft Office 365.

Getting up and Running

VBO365_installThere’s little added value to an Organization running their own email infrastructure, so there has been an explosion in usage of Office 365 over the past few years. The fine folks over at Veeam have recognized this reality and recently released v4 of the Veeam Backup for Office 365 applications. New options provide additional flexibility to cost-effectively store data in Azure Blob storage, in addition to performance enhancements and encryption options.

After downloading the installer, the first thing you might notice is the size of downloads. THEY’RE tiny! When you’re going through the installation and this is the sum total of the options you have during installation, it makes sense as to why the packages are so small. About thirty seconds later you should have a pair of  new applications available to you:

  • Veeam Backup for Office 365
  • Veeam Backup for Microsoft Office 365 PowerShell

Firing up the application for the first time you’ll get a notice about installing a license. I have to say that as a SMB customer, I really appreciate what Veeam has been doing with sharing community editions. When you’re running a small shop, you still need to be able to protect your environment, and having access to a fully functional enterprise class product is extremely valuable. All of the home-labbers out there should also take note. If you’re really trying to test the solution out though, you can get a free 30-day trial license for a fully featured test run of VBO.vbo365_licBefore we move on to getting VBO configured, I’d like to point out that there is a PowerShell module available for VBO, so I’ll sprinkle a couple of those nuggets throughout this post… Like how to install a license using Install-VBOLicense:

vbo_PS_lic

Getting Ready for our first backup

First thing we need to do here, is add an organization that we’ll be backing up. The choices of Organizations we have available to us are: Microsoft Office 365, Hybrid and On-Premises. In this case I’m just going to be targeting a SharePoint instance that is fully in Office 365. VBO_AddOrg

If you want to avoid the GUI you can also use the Add-VBOOrganization cmdlet.

Next you’ll have the opportunity to use the New-VBOOffice365ConnectionSettings cmdlet or the UI to configure your connection to the o365 instance. For the purposes of this blog, we’re just going to stick with Basic Authentication, but you should probably consider using Modern Authentication as MFA and the enhanced security it provides, is highly recommended. Regardless of which direction you go, please make sure to pay attention to the prerequisites guide and particularly the section on permissions.

Backup Time!

That’s what we’re here for right? It’s backup time!

VBO_backup_options
If you’re not into the UI, the Add-VBOJob cmdlet will get this done for you.

We’ve got an Organization, so next we need a job. Click the button for “New Backup Job” or right-click your newly added organization and select the option to “Add to backup job…” After the name and description you have the option to choose what elements you’d like to backup on the “Select objects to back up” vbo_bu_schedulescreen. You can get granular with users, groups, sites or organizations.

Again, to keep things simple we’re just going to tackle the entire organization. If you’d like, on the next screen you can choose objects to exclude from the backup. After selecting the backup proxy’s and the backup repository, you finally have the option to schedule your new awesome Office 365 backups.

That’s IT! Congratulations, in about 10 minutes you’ve managed to provide data protection to your Office 365 environment. I wish this post was longer, but the solution is simple and just works, so there you go! Easy backups of your cloud solution in a matter of minutes

I wish you all a peaceful and joyous holiday season.

PS. For my fellow PowerShell fans, the guide for these modules is quite nice.

PPS. We come to you with a late breaking update from my friend and fellow Vanguard Jim Jones! You can find a best practice guide for VBO at https://vbo.veeambp.com/. I’m not sure how I’ve missed this until now, but you can find a whole host of guides on how to configure your backups according to best practices.

Automate the Auditors Away – Veeam Backup Report v2

Earlier this week I had a piece published over on the Solarwinds Thwack forums titled Start Automating Your Career where I tongue in cheek point out that automation has reached a fever pitch over the last few years. My hope is that by sharing a couple of actionable tips, more people can take their first steps towards scripting and automating.

Given that I was publicly offering advice to people on how to automate their mundane tasks away, I thought that it was only fair if I took my own advice. Or in other words, I was going to eat my own dog food.

In my Thwack piece I offer up three general steps that you can take to get started automating:

  • Pick a Framework
  • Find a Task
  • Use the community

What you’ll find below is proof of my belief in this process, and how I leveraged these tips to automagic one of my problems away.

The Task and Framework

Audit’s are a fact of life in my role and any audit requires a lot of document collection. Anytime you can make that collection process easier, the auditors can expect a more consistent result and you can expect to pull out less hair. Audits happen with some level of regularity and auditors look for consistent data, so there are opportunities abound for standardization and automation of a process. In this case the task is fairly obvious: create a tool to efficiently capture the data necessary for audits. More specifically, I need to get backup documentation for our auditors.

Luckily, we use Veeam Backup and Replication (VBR) for our backups. The fine folks over at Veeam have provided a PowerShell module by default with VBR installations for at least the last several major versions of the product. Recently I used this framework to create a simple script that I describe in Veeam backup report via PowerShell. The script creates a little gap report, but that’s about it. It was fun task, but I got feedback from several folks that took the form of “But what about…” This time around I decided to see how easily I could build a more extensible script, that could have more utility moving forward.

So I’ve identified my task: automate data collection. I’ve also got a framework to use with, the Veeam PowerShell module, so I guess all that’s left is to use the community….

Invoke-vCommunity

A number of years back, I decided that I wanted to become more involved in the community, so I became a VMUG leader. Helping people and networking with like-minded individuals was intoxicating and this past year I took a couple opportunities to further engage, most recently with the Veeam Vanguards. I mention this group, because it’s the Vanguards I reached out to for help with one item of this script.

I just couldn’t get a section of my report to work the way I wanted it to. I knew I was close, but this project was supposed to be fun, and beating your head on your own desk isn’t fun, so I asked for help. It’s not an easy thing to do, but making yourself vulnerable and opening yourself often yields positive results.

Within minutes of posting my question in the Vanguard Slack, my friend Craig popped up and said “Hey, I know someone else who’s having troubles with this too!” Several more minutes go by, and lo and behold, here’s Craig with a KB article to help me out. Ultimately, the KB didn’t provide the fix, but that’s immaterial, as the community and the Vanguards were there to help! The other great thing about the vCommunity, is that there are often opportunities to pay it forward. In the same spirit as Craig sharing the KB, I took a few minutes out of my day to share the resolution on the Veeam forums, on the off chance that someone else needs a helping hand.

The Script

Since I followed my tips, I should have a script right?

I do! It’s a big one, so I’m going to break the script down into a few sections. It is large, so I’m including a link to a downloadable version at the bottom of this post.

The start

First and foremost, I want this script to be helpful and useful. I decided to make use of Parameters to make the process easier to run from the commandline. The use of parameters makes it easier for others to use, with some reasonable expectations of what’s going to happen. I also plan on using this myself, so I made it easy to just run by specifying defaults for many of the parameters. I’ll go another level deeper in a post on parameters very soon-ish.

I’ll also highlight that some of these parameters aspirational. You’ll notice that some are commented out. That’s intentional, to highlight where I think this script could go next. To that end if you try this script out and find it helpful, please let me know and I’ll continue development of it.

Some highlights

  • ReportType is mandatory, because that’s why we’re here.
  • Both OutputType and ReportType leverage Validation Sets to control input values.
  • The Parameter Sets named VBRCred lump parameters together related items
### Define input parameter
[CmdletBinding(DefaultParametersetName='None')]
param(
    [Parameter(ParameterSetName='ReportType',Mandatory=$true)][ValidateSet('All', 'Backup','Copy','History','Gap')][string]$ReportType ="All",
    #[Parameter(ParameterSetName='JobType',Mandatory=$false)][switch]$SingleJob,
    #[Parameter(ParameterSetName='JobType',Mandatory=$true)][string]$JobName,
    [string]$vCenterSvr="vcenter",
    [string]$VBRserver="VBR",
    [ValidateSet( 'HTML')][string]$OutputType='HTML',
    [Parameter(ParameterSetName='VBRCred',Mandatory=$false)][switch]$UseAlternateVBRCredentials  ,
    [Parameter(ParameterSetName='VBRCred',Mandatory=$true)][System.Management.Automation.PSCredential]$VBRCredential   

)

The End or is it the Beginning?

Most of the fun stuff is in the middle of this script, so let’s get the end out of the way first. It’s like eating your salad before getting to the main course. Because I make heavy use of functions, the main routine is simple, clean and readable. Declare a bunch of things I’ll use, make sure the environment is ready and then get to it! You’ll note that I don’t comment everything, but I try to provide comments around the theme of a given section.

The magic in the main routine is the switch statement. If you’ll recall, ReportType was a mandatory parameter. That’s because the operation of this script revolves around the data that we’re gathering. Everything else is a simply a supporting character

#####Main
###Tasks for All, set the variables.
$VBRjobsHistoryArray=@()
$VBRjobsOverviewResults=@()
$ofs=";"
get-veeampluginstatus
connect-vbr

###Do the things based on the parameter things
switch ($ReportType){
  "All"{
    $GapResults=get-gapreport
    $VBRjobs=get-vbrjob
    foreach ($job in $VBRjobs){
      $VBRjobsOverviewResults+=Get-BackupJobOverview -inJob $job
      $VBRjobsHistoryArray+=Get-VBRJobHistoryOverview -injob $job
    }
    break
  }
  "Gap"{
    $GapResults=Get-GapReport
  }
  "History"{
$VBRjobsHistoryArray+=Get-VBRJobHistoryOverview -injob $job
  }
}

###Make it Pretty. Oh so pretty
Build-Output

The Good Stuff!

I stated above that this project needed to be extensible. This script will be broken up in chunks that you can run selectively. I’d also wanted to have the ability to add more functionality in the future, so putting all of the work in functions only makes sense. Here’s a breakdown of what each function does:

  • get-veeampluginstatus. The first function I wrote. How can you tell? I got sloppy with my capitalization. This entire script is predicated on using the VeeamPSSnapIn that’s part of the VBR install, so obvious starting place is to verify that it’s installed and loaded. This and the connect-vbr function are just about getting ready to do work.
  • Get-BackupJobOverview. The first thing auditors want to know is the overview of what you’re doing with your backups. That’s what we’re doing here, creating a basic output for our friends. I really like using custom PowerShell Objects, and you’ll see a few of them throughout this script. I have another post in the work on these nifty items, but it’s probably sufficient to point out that a custom PS object is created by using the New-Object commandlet and data is added to our custom object by using the Add-Member Commandlet. You’ll see that I use the same technique in multiple places, which should make for a more readable product. Another reason to use custom PS objects:  I made this script for ME and my teams needs. By using a custom object, it becomes very very easy to swap other data elements in and out to fit your needs, without refactoring the entire script.
  • Get-GapReport is the same content from Veeam backup report via PowerShell, only put into a function, so no reason to cover it again here.
  • get-scheduleoverview along with Get-BackupJobOverview and Get-VBRJobHistoryOverview were where I had a lot of fun and are the most important parts of this script. In each instance I pass in a single Veeam backup Job (CBackupJob) object. There are a ton of both properties (things that make up the object) and methods (things that you can do with the object), so in reality anything you can get out of the GUI, you can get out the PowerShell objects.  A couple of fun examples for how I put the VBR module to work:
    • In the Get-BackupJobOverview function I want to determine if my backup job is a full backup or not. After tinkering around with my friend Get-Member, I realized that the Veeam Backup Job (CBackupJob) object is full of other objects, like the CDomBackupStorageOptions object, which contains… you guessed it a property called EnableFullBackup. You can see how I drill down to the object in line 34 (also sampled immediately below)
        $JobHash | Add-Member -type NoteProperty -name FullBackup -Value $injob.BackupStorageOptions.EnableFullBackup

2019-12-10 22_18_46-Windows PowerShell ISE

    • I also mentioned that there are a lot of methods made available to you from the VBR cmdlets. Honestly most of the data is surfaced within the Job object itself, but if you want to scratch a little deeper… I make use of a couple methods in the Get-VBRJobHistoryOverview function. On line 145 and 146 I use the GetBackupStats() and GetDetails() methods respectively. This is  the data that I need, but there’s a ton more you can do to fit your needs. As you can see from the statistics on this one object (another nested object), there’s WAY more that you can get busy with. 2019-12-10 22_33_20-Windows PowerShell ISE

The Dog Food

So what do you get out of this beautiful script? That’s what we’re here for right, to see the proof in the pudding, errr dog food. At the moment there are three primary reports being created, all using the ConvertTo-HTML commandlet to make it look pretty. If you want to explore how it’s output, check out the Build-Output function.

The Backup Overview report tries to boil down what are the most basic key elements to your backup job into one table.

2019-12-15 10_18_42-Clipboard

Similarly the History Overview Report tries to distill down the most recent history of a given job into a digestable format.

HistoryOverviewReport.png

And lastly the Gap Report pulls a list of all VM’s from the vCenter target, compares the list against your various VBR jobs, so that at a glance you can see which VM’s are protected by what jobs.

GapreportHeaderGapreportdetails

The End

That’s the script in a nutshell. There’s a lot more that I could dig into here, so be on the lookout for some additional PowerShell posts soon.

I hope that if you’re using Veeam Backup and Replication, that you start putting their deep PowerShell commandlets to use soon. There’s a lot of power you can and should be taking advantage of there.

Lastly I hope this demonstrates that by choosing a task and diving in, you too can start automating your problems way.

Get your very own pretty dog food script here!

function get-veeampluginstatus{
  if(! $(Get-PSSnapin -Name VeeamPSSnapin -Registered -ea SilentlyContinue) ){
    Write-Host 'This script requires the VeeamPSSnapIn to continue. Please install this and retry.'
    exit
  }
  elseif( ! $(Get-PSSnapin -name VeeamPSSnapIn -ea SilentlyContinue)){
    Add-PSSnapin -Name VeeamPSSnapIn
  }
}
function connect-vbr{
  $session=Get-VBRServerSession -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
  if($session){
    Write-Host "You are already connected to Veeam Backup and Replication $($session.server). This process will continue using the existing session."
  }
  else{
    if($UseAlternateVBRCredentials){
      Connect-VBRServer -Server $VBRserver -Credential $VBRCredential
    }
    else{
      Connect-VBRServer -Server $VBRserver
    }
  }
  if (! $(Get-VBRServerSession -ErrorAction SilentlyContinue -WarningAction SilentlyContinue)){
    write-host "we were unable to connect to $VBRserver. This script cannot proceed without a connection and will now exit."
    #exit
  }
}
function Get-BackupJobOverview($inJob){
  $JobHash=new-object system.object
  #$jobhash=$inJob.Name
  $JobHash | Add-Member -type NoteProperty -name Name -value $injob.Name
  $JobHash | Add-Member -type NoteProperty -name Enabled -value $injob.IsScheduleEnabled
  $JobHash | Add-Member -type NoteProperty -name JobType -value $(if ($injob.IsBackup){"Backup"}Elseif($injob.IsBackupSync){"Copy"})
  $JobHash | Add-Member -type NoteProperty -name FullBackup -Value $injob.BackupStorageOptions.EnableFullBackup
  $JobHash | Add-Member -type NoteProperty -name Description -value $injob.Description
  $JobHash | Add-Member -type NoteProperty -name Schedule -value $(get-scheduleoverview -injob $injob )
  $JobHash | Add-Member -type NoteProperty -name VMs -value $($injob.GetObjectsInJob()| Select-Object -Property name -ExpandProperty name|out-string)
  $JobHash | Add-Member -type NoteProperty -name Target -value $injob.TargetDir
  $JobHash | Add-Member -type NoteProperty -name RetentionCycles -value $injob.BackupStorageOptions.RetainCycles

  return $JobHash
}

function Get-GapReport{
  ### v3 not ready for targetted clusters yet
  ### $targetclusters=@("cl1","cl2")
  $GapJobArray =@()

  ###check if existing vCenter connections match entered
  if($global:DefaultVIServers -and ! ($vcentersvr -in $global:DefaultVIServers.name)){
    write-host "You are not connected to the host specified in the 'vCenterSvr'"
    write-host  "Press 'Y' to continue and disconnect from other sessions. Any other key will end this script. "
    write-host "Continue?  "
    $response = read-host
    if ( $response -ne "Y" ) {  }
    Disconnect-VIServer * -Confirm:$false -Force
  }

  $null=Connect-VIServer $vcentersvr 

  ### Get a hash table from Veeam of all Jobs and member servers
  foreach($Gapjob in Get-VBRJob)
  {
    $GapJobHash=new-object system.object
    $GapVMs=$Gapjob.GetObjectsInJob() | Select-Object -Property name -ExpandProperty name
    $GapJobHash | Add-Member -type NoteProperty -name Name -value $Gapjob.Name
    $GapJobHash | Add-Member -type NoteProperty -name VMs -value $GapVMs
    $GapJobArray +=$GapJobHash
  }

  ###Get all Vm's in the target clusters. Iterate through hash table and if a job match add value to VMArray
  $GapSummaryArray =@()

  Foreach ($GapVM in get-vm){
      $GapVMArray=new-object system.object
      $vname=$(get-vm $GapVM).name
      $GapVMArray|Add-Member -type NoteProperty -name VM -Value $vname

      for ($i=0; $i -lt $GapJobArray.count ;$i++){
        if($GapJobArray[$i].VMs.Count -gt 0){
          if($GapJobArray[$i].VMs -contains $vname ){
            $GapVMArray|Add-Member -type NoteProperty -Name $($GapJobArray[$i].name) -Value "enabled"
          }
          else{
            $GapVMArray|Add-Member -type NoteProperty -Name $($GapJobArray[$i].name) -Value "-"
          }
        }
      }
      $GapSummaryArray +=$GapVMArray
   }
  return $GapSummaryArray
}

function get-scheduleoverview($injob){

  $sched=$injob.ScheduleOptions

  #Daily
  if($Sched.OptionsDaily.enabled -eq $true){
    $ScheduleOverview="Daily; " + $Sched.OptionsDaily.DaysSrv + "; " + $Sched.OptionsDaily.TimeLocal.TimeofDay
  }

  #Monthly
  elseif($Sched.OptionsMonthly.enabled -eq $true){
    $ScheduleOverview="Monthly; " + $Sched.OptionsMonthly.DayNumberInMonth.ToString() + " "
    if(! $Sched.OptionsMonthly.Months.Count -eq 12){
      $ScheduleOverview+=$Sched.OptionsMonthly.Months.ToString()
    }
    if($Sched.OptionsMonthly.DayNumberInMonth -eq "OnDay"){
      $ScheduleOverview+=$sched.OptionsMonthly.DayOfMonth.ToString() + "; "
    }
    else{
      $ScheduleOverview+=$sched.OptionsMonthly.DayOfWeek.tostring() + "; "
    }

    $ScheduleOverview+=$Sched.OptionsMonthly.TimeLocal.TimeofDay.ToString()
  }
  #periodically
  elseif($sched.OptionsPeriodically.Enabled -eq $true){
    $ScheduleOverview="Periodically; Period " + $Sched.OptionsPeriodically.FullPeriod + " minutes; "
  }
  #continuous
  elseif($sched.OptionsContinuous.Enabled -eq $true){
    $ScheduleOverview="Continuous; ; "
  }

  return $scheduleoverview
}

function Get-VBRJobHistoryOverview($injob){

  $History=Get-VBRBackupSession | Where-Object {$_.origjobname -eq $injob.name}
  $History= $history |Sort-Object -Property CreationTime -Descending

  $name=$injob.name
  write-host $name

  $HistoryHash=new-object system.object
  $HistoryHash | Add-Member -type NoteProperty -name Name -value $injob.Name
  if ($History){
    $HistoryHash | Add-Member -type NoteProperty -name LastResult -value $history[0].Result
    $HistoryHash | Add-Member -type NoteProperty -name StartTime -value $history[0].CreationTime
    $HistoryHash | Add-Member -type NoteProperty -name EndTime -value $history[0].EndTime
    $HistoryHash | Add-Member -type NoteProperty -name BackupSize -value $($history[0].GetBackupStats()).BackupSize
    $HistoryHash | Add-Member -type NoteProperty -name Details -value $($history[0].GetDetails())

    $lastfive=@()
    For ($i=0;$i -lt 5; $i++){ $lastfive+=$History[$i].Result}
    $HistoryHash | Add-Member -type NoteProperty -name LastFive -value $($lastfive|out-string)
  }else{
     $HistoryHash | Add-Member -type NoteProperty -name Details -value "No History Found"
  }
  write-host $HistoryHash

  return $HistoryHash
}
<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>
Function Build-Output{
  $OutputFile="VeeamBackupOverview_$(get-date -Format HHmm_ddMMMyy)."
  switch ($OutputType){
    "HTML"{
      $Header=
        @"

          table {
          font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
          border-collapse: collapse;
          width: 100%;
          }
          th {
          padding-top: 12px;
          padding-bottom: 12px;
          text-align: left;
          background-color: #4CAF50;
          color: white;
          }
          TD {border-width: 1px;
          padding: 3px;
          border-style: solid;
          border-color: black;}

"@    ## Must remail left aligned, no whitespace allowed before string terminator
      $OutputFile=$OutputFile+"html"
      $OverviewFrag= $VBRjobsOverviewResults | ConvertTo-Html -As Table -Fragment -PreContent '</pre>
<h2>Overview Report</h2>
<pre>'|Out-String
      $HistoryFrag= $VBRjobsHistoryArray | ConvertTo-Html -As Table -Fragment -PreContent '</pre>
<h2>History Overview Report</h2>
<pre>'|Out-String
      $GapFrag = $GapResults | ConvertTo-Html -As Table -Fragment -PreContent '</pre>
<h2>Gap Report</h2>
<pre>'|Out-String
      ConvertTo-Html -Head $Header -PostContent $OverviewFrag,$HistoryFrag,$GapFrag|Out-File $OutputFile
    }
  }
}
<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>

A Letter to the Veeam Vanguards

In 2000 one of my closest friends was getting married, so he and I went to NYC for a boys weekend. While we were there, we had a party and I made many friends for life and even met my future wife. The minute I got home from that trip, I sat down at my desk and wrote a letter to all my new friends. Unfortunately that letter was lost or otherwise destroyed (I’m looking at you Eric) and with the exception of notes to my son, rarely have I felt compelled to write a similar letter since. Until today.

I’ve been home from my first Veeam Vanguard Summit for about 24 hours now. I had to wait to pen this for two reasons. First, if I penned it immediately when I got home, I may end up married to a number of Vanguards and that’s not right or legal. Secondly, without 12 hours of sleep it would have read “Veeam Vangoiui7ioe79etgjl o87rnngdufi…”

I was pretty excited when I received my email in February acknowledging that I’d been accepted into the Veeam Vanguard program. When we first got together I was struck by the lack of pressure. There were little expectations of promoting the brand or pressure to produce content. The message that I heard was, ‘we want to share with you and in return we’d like your frank feedback’. To be honest, at first I was skeptical and was thinking there was some BS. I was wrong.

The year continues and there are periodic calls and webinars, some cool opportunities and early access to info. Some good, fun chatter on Slack should have tuned me in a little more as to what was to come.

For the Veeam Vanguard summit, we went to Prague. Now, if I stopped here and just shared my thanks, it would have been an experience of a lifetime. Before I move on though, just a few words about Prague. I don’t know if I’ve ever been to a more magical city. The architecture is beyond amazing, the people welcoming, the food delicious and the beer plentiful. Anyone considering going, should stop considering and just start saving your pennies. Prague should be at the top of most bucket lists and I truly hope that I get to visit again in the future.

But we weren’t there to sightsee, this was after all a tech program. I expect to share thoughts about the content specifics from the Summit in the future, so I won’t spend time diving into that here. What I will share about this event is that I’ve never seen such candor from a vendor. Any vendor will tell you about what’s awesome in their products and there was definitely that, but the folks at Veeam also told us where things still need work. We got to see behind the curtains on where things are going. That’s pretty cool and again, if we stopped there, I’d still be appreciative. What really made the product discussions special though, is that our feedback was actively solicited and I know for a fact that feedback will makes it’s way back into the product roadmap and development. Seriously, when can you, as a user, sit down with the head of Development for a billion dollar company, tell them your thoughts and concerns, then watch them hand that feedback directly to their teams? I now know the answer.

A most thoughtful gift, to cap a most amazing trip

For experiences like this, ranking and coming up with what’s “the best” is an exercise in futility. One of the things that make this program the most special and what was the most warming and touching part of this experience was the people. I’ve been involved in other programs, information exchanges, educational programs and the like for years. Only once before (luckily earlier this year, I’m blessed) have I ever experienced such camaraderie. From the Veeam-ers who made the event happen, to the Vanguards who participated, I’m so very great full to have met you. As I told one of the SVP’s at our amazing final event at Staropramen Brewery, I’ve never felt so welcomed into a community and god willing, I’ll get to pay that forward in the future.

To Anton, Rick, Cade, Spiteri and the rest of the technical teams, the content was amazing. Thank you for letting us share our feedback on it. Bring on v10!

To the rest of the Veeam team, Aubrey, Rin, Chelsea, Kirsten, and anyone I may have forgotten, thank you for your support. An extra big thank you to Nikola; what an amazing event you helped put together. I really look forward to working with you again in the future.

Finally, to my fellow Vanguards, thank you for the camaraderie, friendship, laughs and welcoming.

To all of you, it was an amazing adventure. Until I see you next, Cheers!

PS. While they weren’t there, I’d be remiss if I didn’t thank my boss and employer. If I didn’t work for a such a fantastic person and organization, I wouldn’t be able to have experiences like this where I can learn, share and re-energize. You’re the best!

Veeam backup report via PowerShell

Here’s the fun thing about audit’s. That’s right, I said fun and audit in the same breath. The great thing about audits is that they are tedious and repetitive…

Which makes them great candidates for automating!

I have a task in front of me to document our backups. Thankfully we use Veeam, which means I get to PowerShell this bad boy! It’s an audit, so I could make this super simple and just pipe the output from Get-VBRJob to a CSV and call it a day. The problem with that approach is that it doesn’t provide any additional utility beyond the audit.

What would be useful though was if I could take all the servers in my target group and compare them against all of the jobs from Veeam and output a pretty little CSV where you could at a glance tell where everything was. Here’s what I came up with:

function get-veeampluginstatus{
  if(! $(Get-PSSnapin -Name VeeamPSSnapin -Registered -ea SilentlyContinue) ){
    Write-Host "This script requires the VeeamPSSnapIn to continue. Please install this and retry."
    exit
  }
  elseif( ! $(Get-PSSnapin -name VeeamPSSnapIn -ea SilentlyContinue)){
    Add-PSSnapin -Name VeeamPSSnapIn
  }
}

get-veeampluginstatus

$targetclusters=@("cluster1","cluster2")
$JobArray =@()
$vcentersvr="vcenterserver"
$veeamsvr="vbrserver"

if(!$cred){$cred=get-credential}

Connect-VIServer $vcentersvr
Connect-VBRServer -Server $veeamsvr -Credential $cred

### Get a hash table from Veeam of all Jobs and member servers
foreach($job in Get-VBRJob)
{
  $JobHash=new-object system.object
  $vms=$job.GetObjectsInJob() | Select-Object -Property name -ExpandProperty name
  $JobHash | Add-Member -type NoteProperty -name Name -value $job.Name
  $JobHash | Add-Member -type NoteProperty -name VMs -value $vms
  $JobArray +=$JobHash
}

###Get all Vm's in the target clusters. Iterate through hash table and if a job match add value to VMArray
$SummaryArray =@()
foreach ($target in $targetclusters)
{
  foreach($VM in $(get-cluster $target|get-vm)){
    $VMArray=new-object system.object
    $vname=$(get-vm $vm).name
    $VMArray|Add-Member -type NoteProperty -name VM -Value $vname

    for ($i=0; $i -lt $JobArray.count ;$i++){
      if($JobArray[$i].VMs.Count -gt 0){
        if($JobArray[$i].VMs -contains $vname ){
          $VMArray|Add-Member -type NoteProperty -Name $($JobArray[$i].name) -Value "enabled"
        }
        else{
          $VMArray|Add-Member -type NoteProperty -Name $($JobArray[$i].name) -Value "-"
        }
      }
    }
    $SummaryArray +=$VMArray
  }
}

$SummaryArray | Export-Csv "veeam_jobs_$(get-date -Format dd_MM_yyyy).csv" -NoTypeInformation<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>
lines 1-20 In the current format, this report is meant to be run in an ad-hoc fashion, so lines 1-20 are really just setting the scene.
One thing of note, I chose to target clusters in my script. This could very easily be altered to target any container objects in vSphere by altering lines 13 & 35.
lines 24-31 When building reports, I’m a fan of using custom objects, it’s just how I roll. Plus it’s readable and easy to consume. There’s a really good explanation of custom objects and how to use them here. In this case I build a custom object, $JobHash, to hold the couple of bits of info about each job. I’ll come back to this in a few.

Each job object that’s returned by Get-VBRjob has a method associated, GetObjectsInJob(). This method tells us which VMs are in the job. Since the VMs are returned as an object, I’m just selecting the name for use in the report

Then the Add-Member commandlet is used to add the job name and VM names to $JobHash. Finally individual jobs are each added into $JobArray on line 30 before moving on.

lines 35-55 The general premise of this whole section is to take the previously built array of jobs, conveniently named $JobArray,  compare it to the list of VM’s from our $targetclusters and build our output.
lines 38-40 If you remember I said at the beginning, I want a visual report of all VM’s and their job status. So regardless of job status, every VM gets an element in $VMArray from our friend Add-Member.
lines 42-52 For each VM that’s returned on line 37 we iterate through $JobArray and based on whether a match is made or not, an entry is made for that VM-Job combo in the $VMArray table, which is concatenated onto $SummaryArray before moving on to the next VM.
lines 56 We done! Pump out the $SummaryArray to a datestamped csv file.

2019-06-01 13_26_23-veeam_jobs_01_06_2019.csv - ExcelAnd here’s what we get for output. It’s a very simple report, but it hits exactly the mark I was aiming for, which is a way to see at a glance what is configured where. There are also several places where the code could be made more efficient, but this is one case where the destination matters far more than the journey.

Start PowerShell’ing your Backups

VeeamOn was such a great and educational show. For my small part of it, I wanted to share how you can automate the deployment/management of your infrastructure. Why would you want to automate? Seriously, did I really just ask that… Speed and  standardization/predictability are the primary drivers for scripting via PowerShell. Or awesomeness. Yup, we’ll stick with the fact that PowerShell is full of awesomeness.

I started my VeeamOn presentation with an example of just how awesome you can become with your PowerShell scripts. In the first part of the video you see how long it takes a person to manually configure a job. Keep in mind this is someone who pretends to know what they are doing, but still errors happen. The second example shows just how long it takes to implement the exact same job via script. So let’s take a moment to parse the Why’s of PowerShell

  • Speed. When I made this video, I had a practiced each click. It still took 2 minutes and 45 seconds to create a backup job. Conversely, the script took 30 seconds to complete. This is for one machine. Now think about if you’re setting this up for 100 machines… manually you’re looking at 4.5 and half hours. Via script, 50 minutes. Yes this is dirty math as there are many factors that go into the equation, but you can’t argue with the fact that scripting is more efficient, even factoring in the ~20 minutes I spent writing the script.
  • Standardization. I’ve worked with Veeam B&R for a number of years now and as I mentioned above, I practiced the workflow to try and take out any bias from the equation. Still I made an oops. We’re human after all. As you’ll see in the code below, by standardizing you can remove much of the human variable (bad pun intended) and produce a more consistent output.

 

Without further ado, here’s the code and desciptions about what’s going on.

lines 2-3: If the PsSnapIn for Veeam isn’t loaded, let’s go ahead and load it. You’re using ISE right, so you probably want it in your editor session as I talked about here
lines 6-27: When you stop and think about it, backup jobs are complex and have lots of options. This is an uber simple example and still you’ve got 16 lines of configurations. By moving this off into a function you make your code both more readable and repeatable. Thankfully the developers have used very intuitive naming conventions for the job options!
line 32: connect to the Backup and Recovery server. Full disclosure, I set the $cred variable in a previous script and got lazy. Sorry!
lines 6-27: Finally, we are getting to the action. It’s exciting! But it’s also not. We set most of the options already. At this point all we need to do is execute the various VBR cmdlets.

  • Add-VBRViBackupJob
    Short and simple, create the backup job… Or is it????  We create a job, but we also leverage:
    Find-VBRViEntity: Find the VMware entity to backup that we specified in our variables above.
    Get-VBRBackupRepository: Fairly self-explanatory, find the backup repository that the job will use.
  • Set-VBRJobOptions
    There is a flow to objects created via the VBR PowerShell cmdlets. Create the object. Set options on the object. This is the later. These are the options configured in our SetVariables function in lines 19-26.
  • Set-VBRJobAdvancedBackupOptions
    Do I need to explain what this does?
  • Set-VBRJobSchedule
    Again, pretty self-explanatory right?
  • Add-VBRViBackupCopyJob
    Remember when I screwed up in the video above? Why do you have to bring up those painful memories??? Anyway, moving on this one creates a new copy job on the previously set variables.

Each of the above cmdlets have a significant number of options to fit your environment. I’d encourage you to peruse the Veeam PowerShell Reference guide for additional options.

Here’s the code. We’ll cover more advanced workflows in our next post in this series. Stay tuned!

#VeeamOn Simple Backup Job Demo
if( ! $(get-pssnapin -Name VeeamPSSnapIn -ea SilentlyContinue)) {
Add-PSSnapin VeeamPSSnapIn
}

function SetVariables{
$Global:PWord= ConvertTo-SecureString -String "VMware1!" -AsPlainText -Force
$Global:cred=New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList "lab\Administrator", $PWord
$Global:VBRserver="VBR.lab.local"

$Global:VBRBackupName="Gold_Tier_Backup"
$Global:VBRRepositoryName="VBR_Local_Repository"
$Global:VBRBackupEntity="GoldTier"

$Global:VBRBackupCopyName="Gold_Copy"
$Global:VBRReplRepositoryName="VBR_Replication_Repository"

#set JobOptions
$Global:VBRJobOptions=Get-VBRJobOptions -Job $VBRBackupName
$VBRJobOptions.JobOptions.RunManually = $false
$VBRJobOptions.BackupStorageOptions.RetainCycles = 3
$VBRJobOptions.BackupStorageOptions.RetainDays = 7
$VBRJobOptions.BackupStorageOptions.EnableDeletedVmDataRetention = $true
$VBRJobOptions.BackupStorageOptions.CompressionLevel = 6
$VBRJobOptions.NotificationOptions.SendEmailNotification2AdditionalAddresses = $true
$VBRJobOptions.NotificationOptions.EmailNotificationAdditionalAddresses = "test@test.com"
}

#Call SetVariables function
SetVariables

if ( ! $(get-vbrserver -Name $VBRserver) ) {Connect-VBRServer -Credential $cred -Server $VBRserver}
sleep 5

$null=Add-VBRViBackupJob -Name $VBRBackupName -Entity $(find-vbrvientity -Tags -Name $VBRBackupEntity) -BackupRepository $(Get-VBRBackupRepository -Name $VBRRepositoryName)

$null=Set-VBRJobOptions -Job $VBRBackupName -Options $VBRJobOptions

$null=Set-VBRJobAdvancedBackupOptions -Job $VBRBackupName -EnableFullBackup $true -FullBackupDays Friday -FullBackupScheduleKind Daily

$null=Set-VBRJobSchedule -Job $VBRBackupName -DailyKind WeekDays -At 01:00

$null=Add-VBRViBackupCopyJob -DirectOperation -Name $VBRBackupCopyName -Repository $(Get-VBRBackupRepository -Name $VBRReplRepositoryName) -Entity $(find-vbrvientity -Tags -Name $VBRBackupEntity)

 

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!