PowerShell Compare VM inventory with Veeam Backup Jobs

0

If you run Veeam Backup & Replication in your environment and you have many VMs in your VMware vSphere inventory and you want to audit to make sure you have corresponding Veeam Backup jobs in place for those VMs, we can with PowerShell compare VM inventory with Veeam Backup Jobs. Let’s take a quick look at how with a few one line commands we can effectively compare our inventory with our backup jobs.

veeamcomp01 PowerShell Compare VM inventory with Veeam Backup Jobs

PowerShell Compare VM inventory with Veeam Backup Jobs

The script assumes your Veeam backup job names match the virtual machine inventory names.  Let’s look at this quick script a few lines at a time.  The first thing the script does is check connections to both vCenter as well as your Veeam Backup & Replication server.

Next, we simply run the compare using a few one liners with both the Veeam PowerShell commandlets as well as PowerCLI commands to pull cluster information and VM information.

Breakdown – The first line ($backupjobs) gets our Veeam Backup & Replication backup jobs.  The ($prodvms) line as the name implies, gets the production VM names by querying the cluster and piping that into the get-vm command.  The ($differencevms) variable compares the two previous variables and then sends the differences to a text file

Thoughts

The PowerShell integration with Veeam proves to be extremely powerful once again as we can replace very manual and tedious processes with quick automated ones.  Running a quick compare of Veeam jobs compared to VMware inventory can prove very useful for auditing to quickly identify virtual machines that may have been inadvertently left out of backup job creation.