PowerShell script exchange
Post Reply
Salzi
Novice
Posts: 4
Liked: never
Joined: Dec 12, 2023 2:34 pm
Full Name: Matthias Salzwedel
Contact:

Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by Salzi »

Hi, i'm looking for a way to get a list of all backup copy jobs and their objects(backup jobs)

This cmdlet seems to work but the output of "BackupJob" is cut off.

Code: Select all

Get-VBRBackupCopyJob | ft Name,RetentionNumber,BackupJob | Format-Table -Wrap -Autosize
The same happens for csv export.

Code: Select all

Get-VBRBackupCopyJob | ft Name,RetentionNumber,BackupJob | Format-Table -Wrap -AutoSize | Out-File "C:\Users\*****\Documents\test.csv"
A solution with VeeamOne is also welcome.
I could not find any fitting report.
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by Mildur » 1 person likes this post

Hello Matthias

You can use $formatenumerationlimit=-1 to configure the output to unlimited objects (default: 4 objects):

$formatenumerationlimit

Code: Select all

$formatenumerationlimit = -1
Get-VBRBackupCopyJob | format-table Name,RetentionNumber,BackupJob -Wrap -Autosize
Best,
Fabian
Product Management Analyst @ Veeam Software
Salzi
Novice
Posts: 4
Liked: never
Joined: Dec 12, 2023 2:34 pm
Full Name: Matthias Salzwedel
Contact:

Re: Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by Salzi »

This with the "format-list" command has worked for me.
Thanks a lot.
-->

Code: Select all

$formatenumerationlimit = -1
Get-VBRBackupCopyJob | format-list Name,RetentionNumber,BackupJob -Wrap -Autosize
Can i set this issue to solved somewhere?
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by Mildur »

Thank you for sharing the solution.
No need to set the topic "to solved".

Best,
Fabian
Product Management Analyst @ Veeam Software
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by david.domask »

Sorry to add to resolved topic, but I can explain what's happening. BackupJob property is actually a CBackupJob object, not just a normal property:

Code: Select all

PS C:\Users\Administrator> (Get-VBRBackupCopyJob | select BackupJob)|gm


   TypeName: Selected.Veeam.Backup.PowerShell.Infos.VBRBackupCopyJob

Name        MemberType   Definition
----        ----------   ----------
Equals      Method       bool Equals(System.Object obj)
GetHashCode Method       int GetHashCode()
GetType     Method       type GetType()
ToString    Method       string ToString()
BackupJob   NoteProperty CBackupJob[] BackupJob=Veeam.Backup.Core.CBackupJob[]


PS C:\Users\Administrator> (Get-VBRBackupCopyJob | select BackupJob).BackupJob

Job Name                  Type            State      Last Result  Description
--------                  ----            -----      -----------  -----------
vmware-per-job            VMware Backup   Stopped    Success      Created by DDOM-VEEAM-RB4\Administrator at 1/19/20...


PS C:\Users\Administrator> (Get-VBRBackupCopyJob | select BackupJob).BackupJob.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     CBackupJob[]                             System.Array
Any time you see the curly braces {} like this:

Code: Select all

PS C:\Users\Administrator> Get-VBRBackupCopyJob | ft Name,RetentionNumber,BackupJob | Format-Table -Wrap -Autosize

Name             RetentionNumber BackupJob
----             --------------- ---------
12.1-backup-copy               7 {vmware-per-job}  <==== that entry
It's likely an object. You can call specific properties from objects in Select-Object calls like the following:

Code: Select all

PS C:\Users\Administrator> Get-VBRBackupCopyJob | Select Name, RetentionNumber, @{n="SourceJob Name";e={$_.BackupJob.Name}}

Name             RetentionNumber SourceJob Name
----             --------------- --------------
12.1-backup-copy               7 vmware-per-job
the format is:

@{name="display name for shell output";expression={here you can write code block; I use $_.BackupJob.Name to get the name}}

you can shorten Name= and Expression= to n= and e= respectively. I recommend this as opposed to playing with Format-Table as it just means you have deeper understanding of what data you're working with and you'll get fewer surprises when trying to export to other formats.
David Domask | Product Management: Principal Analyst
Salzi
Novice
Posts: 4
Liked: never
Joined: Dec 12, 2023 2:34 pm
Full Name: Matthias Salzwedel
Contact:

Re: Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by Salzi »

Thx. That explains it a little bit deeper but i still get cut off SourceJob Names until i use "$formatenumerationlimit = -1" and "Format-List".
Or your only intention was to explain the Object issue.

I just have recognised that i used Format-Table two times in my first examples. Sorry for the confusion. =)
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Backup Copy Job Objects(included Backup Jobs) cut off PS Output

Post by david.domask »

Just to explain the object issue.

I really cant advise on how you _should_ format it as I don't know your end-destination, but the above should explain what kind of object you're working with and from that, you can decide how to build your report. For such items, I usually would just make a PSCustomObject personally, but it really depends on what you want to do with the data. But just from my experience, understanding the structure of the object(s) you're dealing with reduces the friction later on when trying to build reports.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 13 guests