My Veeam Report

Find the latest version here.

Here’s another case of taking a script that someone has shared and putting your personal tweaks into it.

If there was an area in which I wish Veeam would improve, it would be reporting. Though their answer is VeeamOne, it’s a bit much if you just want the additional backup reports. Fortunately this can be overcome with some creative Powershell. I started with a report called vPowerCLI v6 Army Report which can be found here. I had used this report for quite a while until v7 came along and broke a few items. I decided to take the opportunity to not only fix the issues (where I could) but also add some information to the report. I had also been looking at the SAMReports found here and decided to combine a few bits. Lastly, Tom Sightler had a post here that added the ability to report back VMs that had not been backed up within the given time frame – very nice. I can’t say enough about the original authors, without which, I never could have come up with such a report in the end.

Report info includes

  • Job/Session details over period of time (12,24,Week,Month)
  • VMs with no successful backups
  • Running sessions
  • Sessions with warnings or failures with session level details
  • Repository Details
  • Proxy Details
  • Veeam Services Details
  • License/Support Renewal Date

Update the User-Variables section to suit your needs.

Update 03/25/2014 – Version 1.1.4

  • Misc tweaks/bug fixes
  • Reconfigured HTML a bit to help with certain email clients
  • Added cell coloring to highlight status
  • Added $rptTitle variable to hold report title
  • Added ability to send report via email as attachment
Advertisements

54 thoughts on “My Veeam Report

    1. smasterson Post author

      Hi Ajeje
      The code was chewed up a bit and some of the html markup was stripped. I’ve switched how the code is displayed and should it be easier to work with now.
      Let me know if you still have issues.
      –shawn

      Reply
      1. Ajeje

        Whould be nice to have a link with the full powershell script.

        Whishlist:
        – Able to set a title from config variable
        – Able to have a different e-mail subject if there are jobs with Warning/Errors. So it is possible to filter mails on the client side…
        – HTML colors according to success, warning, errors
        – Able to send e-mail to different recpient according to the results of the jobs. Ex: If success: mail1; if warning: mail1,mail2; if error: mail1,mail2,supervisor-mail

  1. smasterson Post author

    Ajeje – You can hit a link to the Gist at the bottom of the script – this makes it easier to download the entire script. Unfortunately, WordPress does not allow for file hosting (only images), I think a gist is the next best thing.
    I’ve also added a few new tweaks including a title variable and HTML coloring of some of the cells to highlight status.
    Let me know what you think
    –shawn

    Reply
  2. MMK

    Hello I am very very new to power shell. I have saved your code as .pS1 and when I run it using power shell on the Veeam server I get bunch of errors and the an html out put showing the version a job table with no information in it.
    Is all the red in your script suppose to be replace with current relevant information- I am need of guidance thanks.

    Reply
  3. MMK

    Hello Shawn, thank you for you response. I have installed the Add-in and adjusted the script from 3-54 and I am getting all information except for VM with no successful backups section ( is this section for identifying which machine in on ESXi are not part of any backup job?) -I really need this feature since we have over 200 VM in our environment and I don’t know what is not added to Veeam jobs.
    Thank you for all your help.
    MK

    Reply
    1. smasterson Post author

      The missing VM section is highly dependent on ensuring your vcenter name listed on line 16 is exactly how it is shown within Veeam (Backup Infrastructure > Managed Servers > VMware vSphere > vCenter Servers)

      Reply
  4. MMK

    Hello Shaw,sorry to bother you again please I am I have confirmed that I am using the VMware server same as Veeam software. When rung the script on the Veeam server I get the following error and then an HTML with only:
    Repository Details
    Repository Name
    Proxy Details
    License/Support Renewal Date
    AND THE FOLLOWING ERROR:
    Find-VBRObject : Cannot validate argument on parameter ‘Server’. The argument i
    s null. Supply a non-null argument and try the command again.
    At C:\Users\administrator\Desktop\Veeam Report.ps1:443 char:34
    + $vmobjs = Find-VBRObject -Server <<<< $vcenterobj | Where-Object {$_.Typ
    e -eq "VirtualMachine" -and $_.VMFolderName -notlike $script:folderExclude}
    + CategoryInfo : InvalidData: (:) [Find-VBRObject], ParameterBind
    ingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.Po
    werShell.Command.FindVBRObject

    Cannot convert argument "0", with value: "", for "GetObjectsOnHost" to type "Sy
    stem.Guid": "Cannot convert null to type "System.Guid"."
    At C:\Users\administrator\Desktop\Veeam Report.ps1:444 char:66
    + $jobobjids = [Veeam.Backup.Core.CHierarchyObj]::GetObjectsOnHost <<<< ($v
    centerobj.id) | Where-Object {$_.GetItem().Type -eq "Vm"}
    + CategoryInfo : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

    You cannot call a method on a null-valued expression.
    At C:\Users\administrator\Desktop\p\Veeam Report.ps1:453 char:30
    + $jobobjid = $vm.FindParent <<<< ("Datacenter").Id + "\" + $vm.Id
    + CategoryInfo : InvalidOperation: (FindParent:String) [], Runtim
    eException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Add-Member : Cannot bind argument to parameter 'InputObject' because it is null
    .
    At CC:\Users\administrator\Desktop\\Veeam Report.ps1:455 char:19
    + $vm | Add-Member <<<< -MemberType NoteProperty "JobObjId" -Value $jo
    bobjid
    + CategoryInfo : InvalidData: (:) [Add-Member], ParameterBindingV
    alidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
    icrosoft.PowerShell.Commands.AddMemberCommand

    Cannot index into a null array.

    Reply
  5. Hem

    I have one question , if i more than one veeam backup server how script knows about ◦VMs with no successful backups for that particular Server .. or I will query vcenter server server and give me list of all VMS which are not included for particular veeam backup server..

    Reply
  6. smasterson Post author

    Hi Hem,
    Unfortunately this is going to be a limitation of the script as it assumes one backup server is protecting the entire vCenter environment (or multiple vCenters).

    –shawn

    Reply
    1. ericzba

      I think I figured it out. I modified this line in the script:

      $seshList = $allSesh | ?{($_.CreationTime -ge (Get-Date).AddHours(-$HourstoCheck)) -and ($_.State -ne “Working”) -and ($_.JobType -ne “BackupSync”) -and ($_.Name -ne “Lab Backup”)}

      I added the -and ($_.JobType -ne “BackupSync”) -and ($_.Name -ne “Lab Backup”). This excludes Backup Copy Jobs and a specific job I have with the name Lab Backup. Works great now!

      Reply
  7. Rollins

    Hi Shawn

    Great script.

    For the life of me I can’t get it to email multiple recipients have tried @(“recipient1@domain”, “recipient2@domain”) does not seem to like it. Will only email the last recipient in the list. Any ideas ?

    Cheers

    Reply
  8. Stoner

    I am getting also an error. Perhaps you could check.

    #region Report
    # Get Veeam Version
    $VeeamVersion = Get-VeeamVersion
    # HTML Stuff
    $headerObj = @”” im Ausdruck oder in der Anweisung.
    Bei C:\Users\USERNAME\Desktop\MyVeeamReport.ps1:503 Zeichen:16
    + $excludevms_re <<<< gex = (â?~(?i)^(â?~ + (($script:excludevms | ForEach {[regex]::escape($_)}) â?"join â?o|â??)
    + â?~)$â?T) -replace "\\\*", ".*"
    + CategoryInfo : ParserError: (â?"join â?o|â??…$headerObj = @":String) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

    Reply
  9. Stoner

    Never mind. I found it.
    Wrong charset -> $excludevms_regex = (‘(?i)^(‘ + (($script:excludevms | ForEach {[regex]::escape($_)}) –join “|”) + ‘)$’) -replace “\\\*”, “.*”

    Reply
  10. Stoner

    Hello again,

    Another issue:

    Get-Date : Cannot bind parameter ‘Date’. Cannot convert value “10/13/2014” to type “System.DateTime”. Error: “String was not recognized as a valid DateTime.”
    At C:\Users\NAME\Desktop\VeeamReport.ps1:386 char:30
    + $totalDaysLeft = ((Get-Date <<<< $expirationDate) – (get-date)).Totaldays.toString().split(",")[0]
    + CategoryInfo : InvalidArgument: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetDateCommand

    Tried to figure it out myself. But without success.

    Thanks

    Reply
    1. smasterson Post author

      Quick guess has me thinking your date format is different than mine (USA vs World…)

      Try swapping the order in line 384
      $datearray = $datearray[1],$datearray[0],$datearray[2]
      change to
      $datearray = $datearray[0],$datearray[1],$datearray[2]

      This should switch the expiration date retrieved from month/day/year to day/month/year
      I haven’t tested the script at all with different locales…this seems to be the issues you are encountering.

      HTH

      Reply
  11. Georges

    Hi. Thank you for this nice piece of code!

    BTW, I made some modifications to print the list of successful backups (I like having a list of what really happened, so I can be sure that no VM has been forgotten in the batch): let me know if you want me to send my version.

    BR,
    Georges

    Reply
    1. smasterson Post author

      That’s a great addition. I like the idea of being able to toggle the option on or off as it would get cumbersome in large environments. You can send to smasterson via gmail if you’d like.

      Thanks!

      Reply
    1. smasterson Post author

      Glad you like 🙂
      I don’t recall exactly what the issue was but v7 had broken the proxy utilization. I should prolly swing back around and check it out as the functionality was nice.

      Reply
  12. Marko

    Nice repport script. question, is it possible to extract the vm’s from a job?
    I mean we have all the vm’s now in a folder that Veeam takes backup and inside of thet folder is all the vm’s that i need to get the times.

    Reply
  13. Pingback: My Veeam Report v1.2 | Shawn Masterson's Blog

  14. Pingback: My Veeam Report v1.3 with VBR v8 Support | Shawn Masterson's Blog

  15. martijnmoret

    Hi,
    Thanks for this, I really love this script.

    I have just tried it on veeam B&R 8 Patch 1 with VMware 5.1 and see a few errors.
    Can you please take a look?

    WARNING: This cmdlet is obsolete, use Find-VBRViEntity instead
    Method invocation failed because [Veeam.Backup.Core.CHierarchyObj] does not contain a method named ‘GetItem’.
    At E:\MyVeeamReport.ps1:444 char:99
    + … Where-Object {$_.GetItem().Type -eq “Vm”}
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

    Unable to find type [Veeam.Backup.Core.CRemoteWinFileCommander]. Make sure that the assembly that contains this type is loaded.
    At E:\MyVeeamReport.ps1:297 char:33
    + $FileCommander = [Veeam.Backup.Core.CRemoteWinFi …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (Veeam.Backup.Co…inFileCommander:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

    You cannot call a method on a null-valued expression.
    At E:\MyVeeamReport.ps1:298 char:33
    + $storage = $FileCommander.GetDrives([ref]$null) …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Attempted to divide by zero.
    At E:\MyVeeamReport.ps1:280 char:25
    + $repoObj = New-Object -TypeName PSObject -Property @{
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

    regards,
    Martijn

    Reply
  16. Roy

    Unexpected token ‘â?”join â?o|â??) + â?~)$â?T) -replace “\\\*”, “.*”
    foreach ($vm in $vmobjs) {
    $jobobjid = ($jobobjids | Where-Object {$_.ObjectId -eq $vm.Id})
    if (!$jobobjid) {
    $jobobjid = $vm.FindParent(“Datacenter”).Id + “\” + $vm.Id

    all i did was replace the server and paths as required….any ideas?

    Reply
    1. smasterson Post author

      Hi Rob
      Did you happen to use the ‘raw view’ or download option on the Gist? For some reason they are both changing characters on line 461. Try copying from the Gist window itself.
      line 461 (ish depending on version) should read:
      $excludevms_regex = (‘(?i)^(‘ + (($script:excludevms | ForEach {[regex]::escape($_)}) –join “|”) + ‘)$’) -replace “\\\*”, “.*”

      Reply
      1. Roy

        thanks, that was exactly the issue. I’m fairly new to powershell scripting, is there an easy way to only collect the last session for failed jobs instead of seeing the failure plus all 3 retries? We have over 400 vm’s being backed up by about 100 jobs, and 20 of them were failing…it was pretty impossible to read :/

      2. smasterson Post author

        Hey Roy
        The ‘only show last session per job’ has come up a few times now – I’ll see if I can incorporate it in the next version.

        Thanks!

  17. TheAgreeableCow

    I came looking for some Veeam V8 Updates and found this original post (and your V8 updates).

    I think it’s great that you were able to get started from some my scripts and I’m able to streamline some updates based on your work 🙂

    Thanks for the credit and link – I’ll ensure to do the same.

    TheAgreeableCow

    Reply
  18. Michael

    Hi guys,

    always appears the errormessage

    Attempted to divide by zero.
    At C:\Batch\Veeam\VeeamReport\veeamreport.ps1:293 char:25
    + $repoObj = New-Object -TypeName PSObject -Property @{
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

    Thanks
    Michael

    Reply
      1. Michael

        Hi

        I have running the latest version of Reports (1.3) and the latest version of VBR (8.0.0.2021)

        Thanks and Greetings
        Michael

      2. smasterson Post author

        It appears as though the script is unable to determine the free space on your repo(s).
        What types of repositories are you running?
        Is there any info returned in the repo section? If so, are any of your repo’s missing?

      3. Michael

        Hi,

        OK. Ich habe den Fehler gefunden. Es gab noch alte repos welche nicht mehr existieren.

        Thanke für die Hilfe.

        Grüße
        Michael

      4. Michael

        And now in English 🙂

        Hi,

        OK. I have found the error. There were old repos which no longer exist.

        Thanke for help.

        regards
        Michael

  19. Michael

    Hi,

    New questions or suggestions :-):

    1. Is it possible to exclude whole VmWare Date Center?
    We have a vCenter with several small Datacenter (ESXi hosts max. 2) running in the branch office. This will not backup at the central site.

    2. Is it possible to exclude multiple folders?

    3. Is it possible to exclude certain backup jobs?
    We have several daily jobs with certain virtual machines and several weekly jobs with certain virtual machines.
    In the daily report the machines are always displayed under “VMs with no successful backups”, which are only backed up weekly.
    If I can exclude backup jobs, then I can work with two reports. A daily and a weekly with different settings.

    Thanke very much and greetings
    Michael

    Reply
    1. smasterson Post author

      Thanks a bunch for the feedback – always welcomed.

      I’m in process of polishing v1.4 and went ahead and added suggestions #1 and #2.

      Regarding #3 – it could get a bit hairy. I think you hit it on the head with having multiple reports. Configure one for daily and another for weekly with each having different VM/Folder/DC exclusions.

      Reply
  20. Michael

    Hi,

    sehr sehr schön Skript
    Vielen vielen Danke für die Änderungen

    Beste Grüße aus Südtirol
    Michael

    Reply
    1. Michael

      Hi,

      very very nice script
      Many many thanks for the changes

      Best regards from South Tyrol
      Michael

      Reply
  21. Chanda Smith

    Hello Shawn!

    Thank you so much for the script. I am learning how to use power shell to create a report that says what the job is, what vmdk was backed up, if the job was successful or not, and what is the repository. This has been a struggle for me. I tried your script and i’m not sure if I plugged in my specific information correctly. I saw that another person got the same error as me and I’m not clear on the fix for:

    Warning: This cmdlet is Obsolete, use Find-VBRiEntity instead.

    Reply
    1. smasterson Post author

      Hi Chanda – that warning can be disregarded, it is just telling us that the command may not exist in the future, but works fine for now.

      Reply
      1. Chanda Smith

        Thank for replying. Unfortunately, I don’t see an output of the report. I thought it was incomplete.

      2. smasterson Post author

        Are there any errors generated or other odd output in the console?
        Be sure you are running the latest version – currently 1.2 for VBR v7 and 1.4 for VBR v8.
        Could also try setting to save to file as opposed to send email.

  22. Brant

    I’m interested in getting a simple (I think) tabular report of the Veeam Session Report, preferably in a CSV format so that I can then import to Excel for graphing trends. Towards that end, should I just be able to trim everything but the “Job/Session details over period of time (12,24,Week,Month)”?

    I’m very new to PS scripts, and have been mostly successful in modding ’em for my needs, but I’m under a time constraint with this endeavor, so whatever time you could spare to assist would be very much appreciated!

    Reply
  23. Simon Jackson

    This is a great powershell report!!!

    A couple of minor fixes i’d like to see:
    1) Use your ‘exclude list’ within the Successful Sessions section too.
    2) Allow custom colour codes/html headers for SUCCESS/FAILED/Warning/Error/Other; giving the administrator more control – it’s a little difficult to find/change without affecting a large block of the report
    3) In Replica Details, please include the VM name
    4) In Successful Sessions, please include the Job Type (backup/replication) AND sort by type then Job Name (basically group Backup Jobs in order; then Recover jobs in order and finally Replication jobs in order).

    Simon

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s