Veeam Unprotected VMs Report

Updated 7/30/2012

One of the common report request that comes up on the Veeam forums is a method to report which VMs in the environment are being properly backed up.  Currently Veeam has no built in report to compare the VMs in your environment to the VMs that are currently in your backup job, and while comparing this list is pretty easy if you have 20-30 VMs, it can quickly become a challenge as the environment gets larger and becomes more dynamic.  This is my attempt to address the situation and learn some Powershell at the same time.

This script finds all VMs on a single vCenter server and looks through all Backup job sessions in the defined time period (currently 24 hours) and reports if they were successfully backed up or not.

The current “stable” version of this script can be downloaded here (7/3/2012).  This version has to following limitations:

  • Tested only on vCenter/VMware environments
  • Duplicate VM names trip it up
  • Supports only a single vCenter at a time.

The current “development” version of this script is available here (7/30/2012).  The primary enhancements of the development version when compared to the “stable” version are as follows:

  • Proper handling of VMs with duplicate names in different datacenters
  • VMs missing from jobs are listed first in the script output
  • VMs that are found in backups also display Job Name in which they are found
  • Simple wildcards are now support for exclusion list (for example *_replica to exlcude replica VMs)
  • Parameter to define length of history to look for VMs in backup jobs (default 24 hours).

 

Share your thoughts

10 Replies to “Veeam Unprotected VMs Report”

  1. Thanks for sharing this .. has given me a good heads-tart for how to approach scripting veeam backup and replication. However, the script is error-ing for me at the point in which you normalize the exclusion list into a regular expression .. This fails with nothing in the exclusion list, with a single item in the exclusion list or with more than one item in the exclusion list .. and with entries in the exclusion list ..

    Specific error is as follows:
    PS C:\Users\blah\Documents\veeam-ps-scripts> .\verify-backed-up-VMs-in-vcenter-1.ps1
    Unexpected token ‘(‘ in expression or statement.
    At C:\Users\blah\Documents\veeam-ps-scripts\verify-backed-up-VMs-in-vcenter-1.ps1:26 char:78
    + $excludevms_regex = (â?~(?i)^(â?~ + (($excludevms | ForEach {[regex]::escap ( <<<

    I should be debugging this and adding an input, but I am new to PowerShell .. coming from a linux background, powershell will take some getting used to.

    Any suggestions ?

    1. Any chance you happen to be doing a “copy and paste” to get the file rather than downloading it. The reason I think this is because the error message seems to be cut off and it makes me think that something was damaged during the download of the file to your computer. The other hint is that it’s cut off exactly at character 78, which is a common break for some editors.

      I’ve run this in a dozen or so environments at this point and have a lot of users that report success, so it’s definitely would seem to be something different about your setup. Any chance your on an older Windows versions like 2003? Maybe Powershell 1.0? I have no idea if that would cause a problem, but I’ve only ever tested on

  2. Receiving this error with Stable and Dev versions, any ideas?

    Find-VBRObject : Cannot bind parameter ‘Server’. Cannot convert the “vc001a.c3.local” value of type “System.String” to type
    “Veeam.Backup.Core.CHost”.
    At line:1 char:1
    + find-vbrobject
    + ~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Find-VBRObject], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Command.FindVBRObject

  3. The term ‘Get-VBRServer’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check t
    he spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\vm_backup_status_dev.ps1:22 char:28
    + $vcenterobj = Get-VBRServer <<<< -Name $vcenter
    + CategoryInfo : ObjectNotFound: (Get-VBRServer:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    The term 'Find-VBRObject' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\vm_backup_status_dev.ps1:23 char:25
    + $vmobjs = Find-VBRObject <<<< -Server $vcenterobj | Where-Object {$_.Type -eq "VirtualMachine"}
    + CategoryInfo : ObjectNotFound: (Find-VBRObject:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Unable to find type [Veeam.Backup.Core.CHierarchyObj]: make sure that the assembly containing this type is loaded.
    At C:\vm_backup_status_dev.ps1:24 char:47
    + $jobobjids = [Veeam.Backup.Core.CHierarchyObj] <<<< ::GetObjectsOnHost($vcenterobj.id) | Where-Object {$_.GetItem().T
    ype -eq "Vm"}
    + CategoryInfo : InvalidOperation: (Veeam.Backup.Core.CHierarchyObj:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

    You cannot call a method on a null-valued expression.
    At C:\vm_backup_status_dev.ps1:32 char:35
    + $jobobjid = $vm.FindParent <<<< ("Datacenter").Id + "\" + $vm.Id
    + CategoryInfo : InvalidOperation: (FindParent:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
    At C:\vm_backup_status_dev.ps1:34 char:21
    + $vm | Add-Member <<<< -MemberType NoteProperty "JobObjId" -Value $jobobjid
    + CategoryInfo : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCo
    mmand

    The term 'Get-VBRJob' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\vm_backup_status_dev.ps1:46 char:22
    + $vbrjobs = Get-VBRJob <<<< | Where-Object {$_.JobType -eq "Backup"}
    + CategoryInfo : ObjectNotFound: (Get-VBRJob:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    The term 'Get-VBRBackupSession' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\vm_backup_status_dev.ps1:47 char:36
    + $vbrsessions = Get-VBRBackupSession <<<< | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addh
    ours(-$HourstoCheck)}
    + CategoryInfo : ObjectNotFound: (Get-VBRBackupSession:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

  4. Thanks for the script. It is now 2014, do you have a new one that works for Veeam 7 at least?
    I get the error: “This cmdlet is obsolete, use Find-VBRViEntity instead” and no more output.

    Thanks

  5. Wondering if you could help me with this problem:
    Method invocation failed because [Veeam.Backup.Core.CHierarchyObj] doesn’t cont
    ain a method named ‘GetItem’.
    At C:\Users\Administrator\Desktop\CheckBackupJobVeeam.ps1:14 char:108
    + $jobobjids = [Veeam.Backup.Core.CHierarchyObj]::GetObjectsOnHost($vcenterobj.
    id) | Where-Object {$_.GetItem <<<< ().Type -eq "Vm"}
    + CategoryInfo : InvalidOperation: (GetItem:String) [], RuntimeEx
    ception
    + FullyQualifiedErrorId : MethodNotFound

  6. Hi,

    Its great to find these scripts.
    But I couldn’t able to execute these scripts. I got below error while running this script using Veeam Powershell.

    Find-VBRObject : Cannot validate argument on parameter ‘Server’. The argument is null. Provide a valid value for the
    argument, and then try running the command again.
    At C:\VeeamScripts\List of VMs not Backup.ps1:22 char:41
    + foreach ($vm in (Find-VBRObject -Server $vcenterobj | Where-Object {$_.Type -eq …
    + ~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Find-VBRObject], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.FindVBRObject

    I ran the script using the Admin account which configured to access the vCenter server in Veeam.
    I am not good with Scripts, Could you please help me with it
    Do I need to do or check any prerequisites before running this script.

    Regards,
    Chandra

Leave a Reply

Your email address will not be published. Required fields are marked *