PowerShell script exchange
Post Reply
ShowMeYourSkil
Novice
Posts: 8
Liked: never
Joined: Jun 26, 2022 1:04 pm
Contact:

Problems with the query of the Veeam backup status

Post by ShowMeYourSkil »

Hello all,

I am using Powershell to query the status of my backup. However, I get errors in the status query that I can't explain. Can you help me?

WARNING: This cmdlet is no longer supported for computer backup jobs. Use
"Get-VBRComputerBackupJob" instead.

Add-PsSnapin : The Windows PowerShell snap-in "VeeamPSSnapIn" is not installed on this computer.


My PowerShell Code:

Code: Select all

param([string]$excluded_jobs = "")
if($excluded_jobs -ne "")
{
	$excluded_jobs_array = $excluded_jobs.Split(",")
}


#Adding required SnapIn
if((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null)
{
	Add-PsSnapin VeeamPSSnapIn
}


$output_jobs_failed 	= ""
$output_jobs_warning 	= ""
$nagios_output 			= ""
$nagios_state 			= 0

$output_jobs_failed_counter 	= 0
$output_jobs_warning_counter 	= 0
$output_jobs_success_counter 	= 0
$output_jobs_none_counter 		= 0
$output_jobs_working_counter 	= 0
$output_jobs_skipped_counter 	= 0


$jobs = Get-VBRJob

ForEach($job in $jobs)
{
	$status 	= $job.GetLastResult()
	$state 		= $($job.findlastsession()).State
	
	#Parse the date when the job last run 
	$runtime 	= $job.GetScheduleOptions()
	$runtime 	= $runtime -replace '.*Latest run time: \[', ''
	$runtime 	= $runtime -replace '\], Next run time: .*', ''
	$runtime 	= $runtime.split(' ')[0]



I would be very pleased to receive help!
Mildur
Product Manager
Posts: 9847
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Problems with the query of the Veeam backup status

Post by Mildur » 1 person likes this post

Hi

Add-PsSnapin : The Windows PowerShell snap-in "VeeamPSSnapIn" is not installed on this computer.
If you have V11 installed, then there is no need to load the VeeamPSSnapIn. You can remove the part from your script.
V11 uses Modules instead of Snapin's.
WARNING: This cmdlet is no longer supported for computer backup jobs. Use
"Get-VBRComputerBackupJob" instead.
That's just a warning that you should add in your script the new command.
Get-VBRJob lists you computer backup jobs today, but could stop doing that in our next version and only list VM Jobs.
You should add Get-VBRComputerBackupJob in your script for the Agent Backup Jobs.

Thanks
Fabian
Product Management Analyst @ Veeam Software
ShowMeYourSkil
Novice
Posts: 8
Liked: never
Joined: Jun 26, 2022 1:04 pm
Contact:

Re: Problems with the query of the Veeam backup status

Post by ShowMeYourSkil »

Hi Fabian

thanks for your reply

I have now replaced the VBR part. Do you happen to know how I can query the last result of the jobs? At that time with the Get-VBR this went over getresult. However, this now throws me an error message and I can not find any documentation.
ShowMeYourSkil
Novice
Posts: 8
Liked: never
Joined: Jun 26, 2022 1:04 pm
Contact:

Re: Problems with the query of the Veeam backup status

Post by ShowMeYourSkil »

I think I found a solution by accident! I will test this and report afterwards.
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests