PowerShell script exchange
sandwichnova
Novice
Posts: 4 Liked: never
Joined: Jan 17, 2023 10:50 pm
Full Name: Sandwich Nova
Contact:
Post
by sandwichnova » Jan 18, 2023 12:17 am
this post
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: 10170 Liked: 2717 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:
Post
by Mildur » Jan 18, 2023 1:00 am
this post
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:
Post
by sandwichnova » Jan 19, 2023 1:16 am
this post
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: 10170 Liked: 2717 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:
Post
by Mildur » Jan 19, 2023 10:23 am
1 person likes this post
Hello
You're welcome.
You can get all backup sessions with the following command:
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:
Post
by sandwichnova » Jan 19, 2023 10:47 pm
this post
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: 2018 Liked: 672 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:
Post
by oleg.feoktistov » Jan 20, 2023 4:00 pm
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:
Post
by sandwichnova » Jan 23, 2023 12:22 am
this post
Thank you both this should give me what i need.
Users browsing this forum: No registered users and 12 guests