PowerShell script exchange
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

PowerShell Veeam backup status report

Post by pizzim13 » Oct 03, 2011 9:24 pm 1 person likes this post

I wrote the following script a while back to get a single email, once every 24 hours with the status of any job who's last state was in error or warning. For the amount of Veeam servers and backup jobs I have running, getting individual emails for every job (success, failure, or warning) and it's retries was just too much. And the email that can be sent from Enterprise Manager doesn't have enough detail. This script has a lot moving parts but hopefully it can help someone out.

The following is an example of the report's output:
Image
The "msgs" have been truncated for the screenshot.

The following code was written to support multiple Veeam servers, not all code is supported by Veeam, uses a config.xml file, uses Powershell SecureStrings to encrypt passwords (http://technet.microsoft.com/en-us/maga ... 14574.aspx), uses PowerShell Remoting (https://blogs.technet.com/b/heyscriptin ... mands.aspx), runs as a scheduled task, if I had to rewrite this today I would probably change some things but it works :) , and lastly use at your own risk:

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)
				{
				#Not supported by Veeam
				$Info = [Veeam.Backup.Core.CBackupTaskSession]::GetByJobSession(($JobStat.Session | foreach-object {$_.info}).id)
				$JobStat."VM Msg" = ($info | ForEach-Object {$_} | Where-Object {$_.status -ne "Success"}) | 
				Foreach-object {$_ | Select-Object @{Name="VM";Expression={$_.ObjectName}}, @{Name="Reason";Expression={$_.Reason}} | 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 
###
The following is the config file. Fill in the blanks with your info and save the file as config.xml in the same directory as your powershell script. The account you use the authenticate to your Veeam servers must be admins and be a dbo to your Veeam database.

Code: Select all

<!-- file.xml -->
<AppSettings>
	<VeeamSrvs>
		<HostName>veeam-srv1.domain.com</HostName>
		<HostName>veeam-srv2.domain.com</HostName>
		<HostName>veeam-srv3.domain.com</HostName>
	</VeeamSrvs>
	<Creds>
		<Veeam>
			<Username>user@domain.com</Username>
			<EncryptedPass></EncryptedPass>
		</Veeam>
	</Creds>
	<Email>
		<SRV>veeam.domain.com</SRV>
		<From>veeam-report@domain.com</From>
		<To>user@domain.com</To>
	</Email>	
</AppSettings>

Gostev
SVP, Product Management
Posts: 24621
Liked: 3465 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: PowerShell Veeam backup status report

Post by Gostev » Oct 03, 2011 9:43 pm

Nice!

Sethbartlett
Expert
Posts: 282
Liked: 25 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: PowerShell Veeam backup status report

Post by Sethbartlett » Oct 07, 2011 2:35 pm

NICE PETER!!!
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.

FkB|Stan
Novice
Posts: 4
Liked: never
Joined: Nov 02, 2011 4:47 pm
Full Name: FkB|Stan
Contact:

Re: PowerShell Veeam backup status report

Post by FkB|Stan » Nov 02, 2011 4:59 pm

Hello,

Thx for your script. It seems pretty good.

I still receive an issue when I start it.
http://imageshack.us/photo/my-images/577/unledghwu.png
(Sorry it's in french. To summarize : Method call failed because [Veeam.Backup.DBManager.CDBJob] doenst have a method named : GetLastResult)

Do you have any idea why ?
I saw in some forum they use GetLastResult -nq. What's the difference between -ne and -nq?

Thx

FkB|Stan
Novice
Posts: 4
Liked: never
Joined: Nov 02, 2011 4:47 pm
Full Name: FkB|Stan
Contact:

Re: PowerShell Veeam backup status report

Post by FkB|Stan » Nov 03, 2011 10:39 am

I think I found my issue.
I wasnt using Veeam Backup Version 5.0.

Actually :
- Windows Server 2003 SP2 with Powershell v2.0 installed
- Veeam Backup & Replication 5.0 with Powershell KIT
- Powershell Remoting Works (Invoke command working)
- PSSession Works
- PSSnapin Works.


But when I start the script I receive this message :
AVERTISSEMENT : You should update your PowerShell to PowerShell 2.0 version.
(I checked Powershell version on each server, and it's 2.0)

I receive a mail, but it's empty.

I really need help to make this wokring.

Waiting for an answer.

pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: PowerShell Veeam backup status report

Post by pizzim13 » Nov 05, 2011 4:20 am

The path of least resistance would be to test the individual parts of the script on your local veeam server. This way you won't have the extra variable of powershell remoting to troubleshoot. One thing to check is the permissions on the account you are using for ps remoting has on your veeam database. It needs to have administrative rights.

"You should update your PowerShell to PowerShell 2.0 version." pay that warning no mind. It comes up in my environment also.

Do you have multiple veeam servers? If not, rip out the ps remoting bits and run the script locally on your veeam server.

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: PowerShell Veeam backup status report

Post by ThomasMc » Nov 06, 2011 2:35 pm

You should update your PowerShell to PowerShell 2.0 version.
I wonder if Veeam are checking the PS version with $host.version somewhere and throwing this warning.

FkB|Stan
Novice
Posts: 4
Liked: never
Joined: Nov 02, 2011 4:47 pm
Full Name: FkB|Stan
Contact:

Re: PowerShell Veeam backup status report

Post by FkB|Stan » Nov 07, 2011 9:35 am

pizzim13 wrote:The path of least resistance would be to test the individual parts of the script on your local veeam server. This way you won't have the extra variable of powershell remoting to troubleshoot. One thing to check is the permissions on the account you are using for ps remoting has on your veeam database. It needs to have administrative rights.

"You should update your PowerShell to PowerShell 2.0 version." pay that warning no mind. It comes up in my environment also.

Do you have multiple veeam servers? If not, rip out the ps remoting bits and run the script locally on your veeam server.
Ok i'll check Administrative rights.

I tried his scripts on local, remote, different kind of server.
It looks working only on Veeam 5.0, because there are different command btw 4.0 and 5.0 and I still receive an empty email.
I have too much server with different installation (Powershell V1/V2, Veeam 4.0/5.0, PowerShell toolkit), so this script isnt great for me.

However, I started my own script to check Veeam Backup which should working on all kind of Veeam.
Actually, it's working well.

On Veeam 4.0 i'm using FindLastJobSession method to get information.
How Can I get Reason when a Backup Failed?! Or Vm Message?
Which Method should I call?

Thx for your help and answer btw.

Sethbartlett
Expert
Posts: 282
Liked: 25 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: PowerShell Veeam backup status report

Post by Sethbartlett » Nov 07, 2011 1:26 pm

I am not sure what the "Reason" call is for version 4. The method Peter is calling is technically unsupported and had to be grabbed through the DLLs/Code directly. It is a .NET call more-so than powershell, so the difference between 4 and 5 I am not sure about.
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.

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: PowerShell Veeam backup status report

Post by ThomasMc » Nov 07, 2011 4:00 pm

You can't use remoting on PS v1

FkB|Stan
Novice
Posts: 4
Liked: never
Joined: Nov 02, 2011 4:47 pm
Full Name: FkB|Stan
Contact:

Re: PowerShell Veeam backup status report

Post by FkB|Stan » Nov 17, 2011 2:42 pm

Thx for your answers.

I create my own script to test. And I finaly succeeded.
Method between version 4.x and version 5.x are totally different.
So I made a script for version 4 and another one for version 5.

Actually, I can report Veeam Backup Job on a nagios/centreon server + I can receive a mail.

It took me alot of time, but finaly, it's working :d
I'm so happy.


VERSION 4 Exemple for STATUS :
- For a specific job : (Get-VBRJOB $JOBNAME).FindLastJobSession().Status
- For All Job : Get-VBRJob | Select-Object @{Name="Job";Expression={$_.Name}} , @{Name="Status";Expression={$_.LatestStatus}}

VERSION 5 Exemple for STATUS :
- For All Job : Get-VBRJob | Select-Object @{Name="Status";Expression={$_.GetLastResult()}}

ekranz
Novice
Posts: 7
Liked: never
Joined: Jun 23, 2011 1:47 pm
Full Name: Ed Kranz
Contact:

Re: PowerShell Veeam backup status report

Post by ekranz » Jan 23, 2012 10:29 pm

Any chance this has been updated to work with V6?

Sethbartlett
Expert
Posts: 282
Liked: 25 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: PowerShell Veeam backup status report

Post by Sethbartlett » Jan 24, 2012 5:47 am

At a quick glance, this looks like it would work with v6. Are you having issues running it in v6?
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.

pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: PowerShell Veeam backup status report

Post by pizzim13 » Jan 24, 2012 1:40 pm

Nice to hear that people are using it. I have only tinkered with v6. Once we have decided the best way to setup v6 for our environment, I will make revisions to this script and post them when finished. As Seth asked, what issues are you running into?

ekranz
Novice
Posts: 7
Liked: never
Joined: Jun 23, 2011 1:47 pm
Full Name: Ed Kranz
Contact:

Re: PowerShell Veeam backup status report

Post by ekranz » Feb 28, 2012 5:26 pm

I'm actually having the same problem that FkB|Stan had, except I'm using V6.

Code: Select all

PS C:\ps> .\veeamreport.ps1

Id              Name            State      HasMoreData     Location             Command
--              ----            -----      -----------     --------             -------
1               Job1            Running    True            bu1.core.dakota.m... ...
1               Job1            Completed  False           bu1.core.dakota.m... ...
3               Job3            Running    True            bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
1               Job1            Completed  False           bu1.core.dakota.m... ...
3               Job3            Completed  True            bu1.core.dakota.m... $JobStatus = (Get-VBRJ...
WARNING: You should update your PowerShell to PowerShell 2.0 version.
Cannot convert argument "0", with value: "", for "GetByJobSession" to type "System.Guid": "Cannot convert null to type
"System.Guid"."
At C:\ps\veeamreport.ps1:70 char:13
+ $JobStatus = <<<<  Get-Job | Receive-Job
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

PS C:\ps> get-host

Name             : ConsoleHost
Version          : 2.0
InstanceId       : f3d80527-bb3a-4c3f-9e58-710b5b4b1443
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
The Veeam server is running Windows 2008 R2 and the client I'm on is a Windows 7 machine, so I've got PowerShell Version 2 on both.

pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: PowerShell Veeam backup status report

Post by pizzim13 » 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.

crichardson
Enthusiast
Posts: 39
Liked: never
Joined: Dec 09, 2010 1:25 pm
Full Name: Corey
Contact:

Re: PowerShell Veeam backup status report

Post by crichardson » 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?

Vitaliy S.
Product Manager
Posts: 22862
Liked: 1538 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: PowerShell Veeam backup status report

Post by Vitaliy S. » 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?

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: PowerShell Veeam backup status report

Post by ThomasMc » 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/

crichardson
Enthusiast
Posts: 39
Liked: never
Joined: Dec 09, 2010 1:25 pm
Full Name: Corey
Contact:

Re: PowerShell Veeam backup status report

Post by crichardson » Mar 16, 2012 11:05 am

Vitaliy S. wrote: 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: Dec 09, 2010 1:25 pm
Full Name: Corey
Contact:

Re: PowerShell Veeam backup status report

Post by crichardson » 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!!!

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: PowerShell Veeam backup status report

Post by ThomasMc » Mar 16, 2012 1:25 pm

Glad you like it :)

Manfriday
Influencer
Posts: 12
Liked: never
Joined: Sep 15, 2009 6:03 pm
Full Name: Jason Morris
Contact:

Re: PowerShell Veeam backup status report

Post by Manfriday » 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"."

?

Sethbartlett
Expert
Posts: 282
Liked: 25 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: PowerShell Veeam backup status report

Post by Sethbartlett » 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.

tsightler
VP, Product Management
Posts: 5399
Liked: 2229 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: PowerShell Veeam backup status report

Post by tsightler » 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
    ###

Gav@GH
Influencer
Posts: 21
Liked: 15 times
Joined: Jul 20, 2012 12:27 am
Contact:

Re: PowerShell Veeam backup status report

Post by Gav@GH » 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 http://forums.veeam.com/viewtopic.php?f=26&t=13422

ekranz
Novice
Posts: 7
Liked: never
Joined: Jun 23, 2011 1:47 pm
Full Name: Ed Kranz
Contact:

Re: PowerShell Veeam backup status report

Post by ekranz » 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!

pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: PowerShell Veeam backup status report

Post by pizzim13 » 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

tsightler
VP, Product Management
Posts: 5399
Liked: 2229 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: PowerShell Veeam backup status report

Post by tsightler » Feb 25, 2013 3:32 pm

The same issue is also documented here on the forums at http://forums.veeam.com/viewtopic.php?f ... +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).

jayp2200
Lurker
Posts: 2
Liked: never
Joined: Mar 04, 2013 2:07 pm
Full Name: Jason Prepodnik
Contact:

Re: PowerShell Veeam backup status report

Post by jayp2200 » 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?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest