PowerShell Veeam backup status report

PowerShell script exchange

Re: PowerShell Veeam backup status report

Veeam Logoby pizzim13 » Mon Mar 05, 2012 2:57 pm

Since I don't have v6 installed I cannot help you troubleshoot this. I have crudely bolted on more tables to this report since its initial posting so I see a rewrite in my v6 future.
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Re: PowerShell Veeam backup status report

Veeam Logoby crichardson » Wed Mar 07, 2012 2:39 pm

I'd love to see a script that will work with v6. We currently have both replication and backups jobs. Rather than receiving a bunch of emails for each job, I'd rather just see a full report sent at the same time every day. I'm sure, in future releases of B&R, we will probably see a built-in session/report manager which would be able to store historical details. But for now, a daily email report seems to be the only option. Has anyone successfully used this on Server 2008 R2 with V6?
crichardson
Enthusiast
 
Posts: 39
Liked: never
Joined: Thu Dec 09, 2010 1:25 pm
Full Name: Corey

Re: PowerShell Veeam backup status report

Veeam Logoby Vitaliy S. » Wed Mar 07, 2012 4:39 pm

crichardson wrote:We currently have both replication and backups jobs. Rather than receiving a bunch of emails for each job, I'd rather just see a full report sent at the same time every day

But this is possible even today with Enterprise Manager, have you had a chance to review it?
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: PowerShell Veeam backup status report

Veeam Logoby ThomasMc » Wed Mar 14, 2012 8:22 pm

Bit of a shameless plug but check this out :D

http://vpowercli.net/2012/01/23/vpowerc ... my-report/
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: PowerShell Veeam backup status report

Veeam Logoby crichardson » Fri Mar 16, 2012 11:05 am

Vitaliy S. wrote:
crichardson wrote:We currently have both replication and backups jobs. Rather than receiving a bunch of emails for each job, I'd rather just see a full report sent at the same time every day

But this is possible even today with Enterprise Manager, have you had a chance to review it?


The only thing I've been able to see in the Enterprise Manager is a daily report that tells me how many errors/warnings/success there was. But thats it, no details as to what jobs failed or anything like that.
crichardson
Enthusiast
 
Posts: 39
Liked: never
Joined: Thu Dec 09, 2010 1:25 pm
Full Name: Corey

Re: PowerShell Veeam backup status report

Veeam Logoby crichardson » Fri Mar 16, 2012 11:33 am

ThomasMc wrote:Bit of a shameless plug but check this out :D

http://vpowercli.net/2012/01/23/vpowerc ... my-report/

Amazing. Everything I needed. Thanks!!!
crichardson
Enthusiast
 
Posts: 39
Liked: never
Joined: Thu Dec 09, 2010 1:25 pm
Full Name: Corey

Re: PowerShell Veeam backup status report

Veeam Logoby ThomasMc » Fri Mar 16, 2012 1:25 pm

Glad you like it :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: PowerShell Veeam backup status report

Veeam Logoby Manfriday » Fri Jun 08, 2012 7:30 pm

has anyone ever figured out a work-around for the error message when using Version 6?

Cannot convert argument "0", with value: "", for "GetByJobSession" to type "System.Guid": "Cannot convert null to type "System.Guid"."

?
Manfriday
Novice
 
Posts: 9
Liked: never
Joined: Tue Sep 15, 2009 6:03 pm
Full Name: Jason Morris

Re: PowerShell Veeam backup status report

Veeam Logoby Sethbartlett » Mon Jun 11, 2012 4:36 am

As stated, the script does not work for version 6. There is not a work-around per-se, a re-write would need to be done. The error you are getting simply means you are getting no data. It cannot convert nothing into something is what that error means.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: PowerShell Veeam backup status report

Veeam Logoby tsightler » Sat Jun 16, 2012 3:26 am 1 person likes this post

Due to the number of request for a similar script for V6 here is my first quick pass at updating this script to work with VBR 6.x. The change was very minor, basically removing the "unsupported" call and replacing it with a call to a couple of new methods available in the 6.x powershell interface. Tested very lightly in my lab, but please feel free to give it a try and report.

Code: Select all
$ErrorActionPreference = "stop"

    #html styling
    $style = "<style>"
    $style = $style + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $style = $style + "TH{border-width: 1px;padding: 1px;border-style:double;border-color: black;}"
    $style = $style + "TD{border-width: 1px;padding: 5px;border-style:double;border-color: black;}"
    $style = $style + "</style>"

    #For debugging
    #Get-PSSession | Remove-PSSession

    #Reading config file
    $ScriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
    $Config = [xml](Get-Content "$ScriptPath\config.xml")

    ###Create a new PSSession to each server in $VeeamSrvs and assign to a variable
    $VeeamCreds = New-Object System.Management.Automation.PSCredential $Config.AppSettings.Creds.veeam.username, ($Config.AppSettings.Creds.veeam.EncryptedPass | ConvertTo-SecureString)

    $VeeamSrvSessions = New-Object System.Collections.ArrayList
    foreach ($VeeamSrv in $Config.AppSettings.VeeamSrvs.HostName)
       {
       $VeeamSrvSessions.add((New-PSSession -ComputerName $VeeamSrv -Credential $VeeamCreds)) | out-null
       }
    ###

    ###Connect to each Veeam Server and add the Veeam Snapin
    foreach ($VeeamSrvSession in $VeeamSrvSessions)
       {
       Invoke-Command -session $VeeamSrvSession -ScriptBlock `
          {
          #Add Veeam snapin if needed
          if ( (Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null )
             {
             Add-PsSnapin -Name VeeamPSSnapIn
             }
          } -AsJob
       }
    Get-Job | Wait-Job
    ###

    ###Connect to all Veeam servers and return status on jobs that have warnings or failures and have completed within the last day
    foreach ($VeeamSrvSession in $VeeamSrvSessions)
       {
        Invoke-Command -session $VeeamSrvSession -ScriptBlock `
          {$JobStatus = (Get-VBRJob | Where-Object {$_.GetLastResult() -ne "Success" -and $_.GetLastResult() -ne "None" -and $_.findlastsession().progress.stoptime -ge (Get-Date).addhours(-24)}) |
          ForEach-Object {$_ | Select-object  @{Name="Job";Expression={$_.Name}}, @{Name="Status";Expression={$_.GetLastResult()}}, `
             @{Name="ID";Expression={$_.id}}, @{Name="Job Msg";Expression={$_.FindLastSession().info.description}}, @{Name="Session";Expression={$_.FindLastSession()}}}
                   
          if ($JobStatus -ne $null)
             {
             #Adding new properties to array
             $JobStatus | ForEach-Object {$_ | Add-Member -MemberType NoteProperty "Server" -Value $Env:COMPUTERNAME}
             $JobStatus | ForEach-Object {$_ | Add-Member -MemberType NoteProperty "VM Msg" -Value $null}
             
             #Collecting VM failure info
             foreach ($JobStat in $JobStatus)
                {
                $Info = $JobStat.Session.GetTaskSessions()
                $JobStat."VM Msg" = ($info | ForEach-Object {$_} | Where-Object {$_.status -ne "Success"}) |
                Foreach-object {$_ | Select-Object @{Name="VM";Expression={$_.Name}}, @{Name="Reason";Expression={$_.GetDetails()}} | Format-List | Out-String}
                }
             $JobStatus
             }
          } -AsJob
       }
       
    Get-Job | Wait-Job
    $JobStatus = Get-Job | Receive-Job
    ###

    #Closing open PS sessions
    Get-PSSession | Remove-PSSession

    ###Sending report
    #Mail settings
    $MailSrv = $Config.AppSettings.Email.SRV
    $MailFrom = $Config.AppSettings.Email.From
    $MailTo = $Config.AppSettings.Email.To
    $MailSbjt = "Veeam Job Status Report $(get-date)"
    $MailBody = ($JobStatus | Select-Object Job, Status, "Job Msg", "VM Msg", Server | Sort-Object Status -Descending |   ConvertTo-Html -Head $style | Out-String) `
             -replace ("VM     :","<p></p><b>VM:</b>") `
             -replace ("Reason :","<p></p><b>Reason:</b>") `
             -replace ("<td>Failed","<td bgcolor=red>Failed")

    Send-MailMessage -SmtpServer $MailSrv -From $MailFrom -To $MailTo -Subject $MailSbjt -Body $MailBody -BodyAsHtml
    ###
tsightler
Veeam Software
 
Posts: 4775
Liked: 1740 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: PowerShell Veeam backup status report

Veeam Logoby Gav@GH » Fri Sep 14, 2012 9:32 pm

I have done some work on collating a number of reporting scripts into a single backup status report.

Check out the post over in this thread viewtopic.php?f=26&t=13422
Gav@GH
Influencer
 
Posts: 21
Liked: 15 times
Joined: Fri Jul 20, 2012 12:27 am

Re: PowerShell Veeam backup status report

Veeam Logoby ekranz » Mon Feb 25, 2013 2:27 pm

We had this report running last year, but in the process of updating to 6.5 and moving from a local SQL server to remote sql, the report is now failing.

Code: Select all
PS D:\Reports> .\test.ps1

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                 
--     ----            -------------   -----         -----------     --------             -------                 
10     Job10           RemoteJob       Running       True            bu1.core.dakota.m... ...                     
2      Job2            RemoteJob       Completed     False           bu1.core.dakota.m... ...                     
4      Job4            RemoteJob       Completed     False           bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
6      Job6            RemoteJob       Completed     False           bu1.core.dakota.m... ...                     
8      Job8            RemoteJob       Completed     False           bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
10     Job10           RemoteJob       Completed     False           bu1.core.dakota.m... ...                     
12     Job12           RemoteJob       Running       True            bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
2      Job2            RemoteJob       Completed     False           bu1.core.dakota.m... ...                     
4      Job4            RemoteJob       Completed     False           bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
6      Job6            RemoteJob       Completed     False           bu1.core.dakota.m... ...                     
8      Job8            RemoteJob       Completed     False           bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
10     Job10           RemoteJob       Completed     False           bu1.core.dakota.m... ...                     
12     Job12           RemoteJob       Completed     True            bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
WARNING: You should update your PowerShell to PowerShell 2.0 version.
SQL server is not available
At D:\Reports\test.ps1:69 char:5
+     $JobStatus = Get-Job | Receive-Job
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Veeam.Backup.Po...mmand.GetVBRJob:GetVBRJob) [Get-VBRJob], CAppException
    + FullyQualifiedErrorId : Backup,Veeam.Backup.PowerShell.Command.GetVBRJob
    + PSComputerName        : bu1.core.dakota.mn.us


Any ideas? I've tried other reports, but the information and formatting of this one is spot on for our needs.
(The powershell version is 3.0)

Any help would be greatly appreciated!
ekranz
Novice
 
Posts: 7
Liked: never
Joined: Thu Jun 23, 2011 1:47 pm
Full Name: Ed Kranz

Re: PowerShell Veeam backup status report

Veeam Logoby pizzim13 » Mon Feb 25, 2013 2:33 pm

If you are using a remote sql server it is probably a problem with credssp 2nd hop authentication. http://blogs.msdn.com/b/powershell/arch ... count.aspx This article will show you how to turn it on
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Re: PowerShell Veeam backup status report

Veeam Logoby tsightler » Mon Feb 25, 2013 3:32 pm

The same issue is also documented here on the forums at viewtopic.php?f=26&t=13075&start=0&hilit=andys+scripting and includes a simple script to set all parameters (including a parameter to increase the shell memory which can also be an issue that causes a similar problem).
tsightler
Veeam Software
 
Posts: 4775
Liked: 1740 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: PowerShell Veeam backup status report

Veeam Logoby jayp2200 » Mon Mar 04, 2013 2:13 pm

ThomasMc wrote:Bit of a shameless plug but check this out :D

http://vpowercli.net/2012/01/23/vpowerc ... my-report/



This works great for us as well with one exception. For any job that fails, is it possible to add which one failed and/or if the issue had been resolved?
jayp2200
Lurker
 
Posts: 2
Liked: never
Joined: Mon Mar 04, 2013 2:07 pm
Full Name: Jason Prepodnik

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: Google [Bot] and 7 guests