PowerShell script exchange
Post Reply
Marco-ITSM
Service Provider
Posts: 1
Liked: never
Joined: Dec 21, 2016 2:33 pm
Full Name: Marco Hahnen
Contact:

[Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by Marco-ITSM »

Hi,

we just upgraded our Veeam Installation from v11 to v12.

In one of our powershell scripts, I call the following function, because its faster than get-vbrjob:

Code: Select all

[Veeam.Backup.Core.CBackupJob]::GetAll()
which in v12 generates the following error:

Code: Select all

Exception calling "GetAll" with "0" argument(s): "Object reference not set to an instance of an object."
At line:1 char:1
+ [Veeam.Backup.Core.CBackupJob]::GetAll()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException
Now the fun part: if i call get-vbrjob before calling the .net function, the .net function works fine afterwards.

Image

any ideas?
david.domask
Veeam Software
Posts: 2648
Liked: 613 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: [Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by david.domask »

Hi @Marco-ITSM, check my answer here:

post480167.html#p480167

Basically, this is kind of one of the risks of using .NET reflection :) It's not supported method; I get why you're using it, and hopefully we will see improvements on the officially supported cmdlets in the future, but for now you'll need to use this workaround for your scripts relying on .NET reflection.
David Domask | Product Management: Principal Analyst
Silent
Novice
Posts: 8
Liked: never
Joined: Jan 23, 2025 10:55 am
Full Name: Silent
Contact:

Re: [Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by Silent »

Sorry for posting on an old topic but I did not want to open up a new one about the exact same issue.
There are quite some very valid reason to use static .NET methods.
Did anyone figure out the .NET reflections not fully loading/initiating?
I'm running a PSmodule cmdlet to make it work but it would be nice to know and understand why this issue exists.
david.domask
Veeam Software
Posts: 2648
Liked: 613 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: [Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by david.domask »

Hi Silent,

I'm glad that the workaround is working, but as .NET Reflection is not supported officially, I'm not sure that it's worth spending time to go deeper into an unsupported operation.

For any of the situations where you're currently using .NET reflection with Veeam it's best to instead find a supported way or create a feature request for proper handling with a supported cmdlet. .NET Reflection can be quite dangerous in this case as I believe you understand, so in an ideal world we aren't exposing any of these methods through our cmdlets as it will allow for too many dangerous situations.

So if you're heavily relying on it for your Veeam scripts with Veeam cmdlets, I would advise create a new topic and see if there are supported solutions for what you're doing/make a feature request for proper handling.

Thanks!
David Domask | Product Management: Principal Analyst
Silent
Novice
Posts: 8
Liked: never
Joined: Jan 23, 2025 10:55 am
Full Name: Silent
Contact:

Re: [Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by Silent »

The supported ways have major issues (for a sysadmin) that are not practicable with a zero-fault-tolerance policy/mindset.
Also there currently is no supported way to check on Proxmox and Nutanix jobs at all. Only works with static methods.
david.domask
Veeam Software
Posts: 2648
Liked: 613 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: [Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by david.domask »

Understood re:limitations on supported cmdlets and the lack of options for Proxmox/Nutanix. API (including Powershell) support for other hypervisors is planned, but no ETA at the moment.

As for .NET reflection, as noted, as it's not supported and there is a practical and simple workaround, I'd ask please use the workaround and simply include any official cmdlet prior to the .net reflection.

e.g.,

Get-VBRLicenseAutoUpdateStatus | Out-Null

It's fast and simple call, and from there you will be able to use .NET reflection within your script. Please do create topics for situations where you're not able to find a supported means of completing the task, and use the forum search as there may be solutions existing already for some items.
David Domask | Product Management: Principal Analyst
Silent
Novice
Posts: 8
Liked: never
Joined: Jan 23, 2025 10:55 am
Full Name: Silent
Contact:

Re: [Veeam.Backup.Core.CBackupJob] - Object reference not set to an instance of an object. (v12)

Post by Silent »

I already know, but thank you nonetheless.
Also using static methods I already am monitoring Nutanix and Proxmox backup jobs. The backend design of those are questionable but that's none of my business - got it working properly and in a reliable fashion.
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests