PowerShell script exchange
Post Reply
alexis.courteix
Novice
Posts: 6
Liked: never
Joined: Mar 21, 2018 8:41 am
Full Name: Alexis Courteix
Location: Clermont-Ferrand
Contact:

Get Backup Job's Target Repository

Post by alexis.courteix » Jan 15, 2020 1:32 pm

Hello all,

I'm looking for the proper way to retrieve my Backup Jobs' Target Repositories Names.
While I get some settings through the job's options, it seems more complicated to retrieve this information.

I thought the TargetDir property would be enough but it's not always filled it seems, and returns the path associated with the repository when I get something.

Code: Select all

ForEach($BackupCopyJob in (Get-VBRJob | ? {$_.JobType -eq "BackupSync"} | Sort-Object Name)){
     $Options = $BackupCopyJob.GetOptions()
     $Properties = New-Object Psobject

     $Properties | Add-Member -type Noteproperty -name JobName -value $BackupCopyJob.Name
     $Properties | Add-Member -type Noteproperty -name Description -value $BackupCopyJob.NameWithDescription
     $Properties | Add-Member -type Noteproperty -name IsScheduledEnabled -value $BackupCopyJob.IsScheduleEnabled
     $Properties | Add-Member -type Noteproperty -name RestorePointsToKeep -value $Options.generationpolicy.SimpleRetentionRestorePoints
     $Properties | Add-Member -type Noteproperty -name GFSMonthlyBackups -value $Options.generationpolicy.GFSMonthlyBackups
     $Properties | Add-Member -type Noteproperty -name GFSYearlyBackups -value $Options.generationpolicy.GFSYearlyBackups
     $Properties | Add-Member -type Noteproperty -name RetentionPolicyType -value $Options.generationpolicy.RetentionPolicyType
     $Properties | Add-Member -type Noteproperty -name Path -value $BackupCopyJob.TargetDir

     Write-Output $Properties
}
Any ideas ?

Egor Yakovlev
Veeam Software
Posts: 827
Liked: 213 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Contact:

Re: Get Backup Job's Target Repository

Post by Egor Yakovlev » Jan 15, 2020 3:41 pm 1 person likes this post

Hi Alexis, try :

Code: Select all

$Properties | Add-Member -type Noteproperty -name Target -value $BackupCopyJob.GetTargetRepository().Name
/Cheers!

alexis.courteix
Novice
Posts: 6
Liked: never
Joined: Mar 21, 2018 8:41 am
Full Name: Alexis Courteix
Location: Clermont-Ferrand
Contact:

Re: Get Backup Job's Target Repository

Post by alexis.courteix » Jan 15, 2020 4:17 pm

Thanks Egor !
Works as a charm :)

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests