PowerShell script exchange
Post Reply
sandwichnova
Novice
Posts: 4
Liked: never
Joined: Jan 17, 2023 10:50 pm
Full Name: Sandwich Nova
Contact:

Data Export

Post by sandwichnova »

Hey Guys

I’m trying to export the history for all our backup jobs to then import into PowerBI.

I’ve got the below to work but it’s only returning the backup copy job types and ignoring our Windows Agent and Policy jobs.

Is there another command to pull out these other types or what am I missing?

Code: Select all

Get-VBRBackupSession | Sort-Object EndTime -Descending | Select-Object -first 10 -Property JobName,CreationTime,EndTime,result,State,AuxData,JobId,JobType | Export-Csv 'C:\Users\
Version: 11.0.1.1261
Mildur
Product Manager
Posts: 8735
Liked: 2296 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Data Export

Post by Mildur »

Hello

Welcome to the forum.
For Agents we have another command you should check out:
- Get-VBRComputerBackupJobSession

For standalone agents, this cmdlet must be used:
- Get-VBREPSession

Best,
Fabian
Product Management Analyst @ Veeam Software
sandwichnova
Novice
Posts: 4
Liked: never
Joined: Jan 17, 2023 10:50 pm
Full Name: Sandwich Nova
Contact:

Re: Data Export

Post by sandwichnova »

Thanks Fabian that's great!

Is it possible to get the data information out of the session? (Processed, Read, Transferred)

I can use the below to get the information but I need it from all pervious sessions.

Code: Select all

$job = Get-VBRJob -name "Backup Job"
$job.FindLastSession()
Mildur
Product Manager
Posts: 8735
Liked: 2296 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Data Export

Post by Mildur » 1 person likes this post

Hello

You're welcome.
You can get all backup sessions with the following command:

Code: Select all

Get-VBRBackupSession
Session data (Processed, Read, Transferred) is stored in .SessionInfo.progress

Code: Select all

$session = Get-VBRBackupSession
$session[0].SessionInfo.progress
Best,
Fabian
Product Management Analyst @ Veeam Software
sandwichnova
Novice
Posts: 4
Liked: never
Joined: Jan 17, 2023 10:50 pm
Full Name: Sandwich Nova
Contact:

Re: Data Export

Post by sandwichnova »

Thanks that worked great for the backup copy jobs but what about the agent and standalone agent jobs?

Returns results but only backup copy jobs

Code: Select all

$session = Get-VBRBackupSession
$session[0].SessionInfo.progress
Returns nothing:

Code: Select all

$session = Get-VBRComputerBackupJobSession
$session[0].SessionInfo.progress
Returns nothing:

Code: Select all

$session = Get-VBREPSession
$session[0].SessionInfo.progress
When I look up the commands, they seem to be missing the same properties I need.

Code: Select all

Get-VBREPSession | Get-Member
Get-VBRComputerBackupJobSession | Get-Member
I feel like there is something very basic I’m missing here, and I just can’t see it.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Data Export

Post by oleg.feoktistov » 2 people like this post

Hi,

Reflecting statistics is not supported in VBREPSession and VBRComputerBackupJobSession types. So the only, though not officially supported, way now would be to present session objects as CBackupSession type and look at Progress property there.
For standalone agent jobs:

Code: Select all

$jobs = Get-VBREpJob
foreach ($job in $jobs) {
$sessions = [Veeam.Backup.Core.CBackupSession]::GetByJob($job.Id)
$sessions[0].Progress
}
For agent management jobs:

Code: Select all

$jobs = Get-VBRComputerBackupJob
foreach ($job in $jobs) {
$sessions = [Veeam.Backup.Core.CBackupSession]::GetByJob($job.Id)
$sessions[0].Progress
}
Best regards,
Oleg
sandwichnova
Novice
Posts: 4
Liked: never
Joined: Jan 17, 2023 10:50 pm
Full Name: Sandwich Nova
Contact:

Re: Data Export

Post by sandwichnova »

Thank you both this should give me what i need.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests