PowerShell script exchange
Post Reply
FabrizioA
Lurker
Posts: 1
Liked: never
Joined: Sep 07, 2017 9:11 am
Full Name: Fabrizio Alongi
Contact:

Error [Veeam.Backup.DBManager.CDBManager] not found

Post by FabrizioA »

Hi,

I created a script to retrieve the "current/last" backup status of a VM within veeam jobs.
In this script I've used the "[Veeam.Backup.DBManager.CDBManager]" class that has the function of displaying all backup sessions with relative details.
If I run the command (which includes the above mentioned class):

Code: Select all

$Sessions= foreach ($bsession in ([Veeam.Backup.DBManager.CDBManager]::Instance.BackupJobsSessions.GetAll() | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}))
    {
        Get-VBRTaskSession ([Veeam.Backup.Core.CBackupSession]::Create($bsession, $null))
    }

directly from powershell there is no problem, but if I invoke the same script form Windows CMD prompt by this way:

Code: Select all

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe  -file C:\Zabbix\veeam\Veeam_VM_Status.ps1 "[VM_NAME]" "[JOB_NAME]"
I get this error:

Code: Select all

The [Veeam.Backup.DBManager.CDBManager] type could not be found. Verify that "the assembly" containing this type is loaded.

In C:\Zabbix\veeam\Veeam_VM_Status.ps1:45 car:73
+    $Sessions= foreach ($bsession in ([Veeam.Backup.DBManager.CDBManager] <<<<
 ::Instance.BackupJobsSessions.GetAll() | Where-Object {$_.JobType -eq "Backup"
 -and $_.EndTime -ge (Get-Date).addhours(-24)}))
    + CategoryInfo          : InvalidOperation: (Veeam.Backup.DBManager.CDBMan
   ager:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Where can I find or how can I put the assembly not found" and solve the problem? Any suggestions?

Thank you
F.
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Error [Veeam.Backup.DBManager.CDBManager] not found

Post by tdewin »

Did you load the snapin in your script?

Anyway using this technique of calling dotnet classes directly is not a recommended approach. It might be break your code even between updates. In this case it is highly recommended to use the appropriate cmdlets like get-vbrbackupsession and get-vbrtasksession:
https://helpcenter.veeam.com/docs/backu ... ssion.html
Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests