I don't know, it works fine for me. At first guess I'm thinking you are possibly using SMB/CIFS/DDboost repos with the gateway set to "auto" which technically means they are all owned by the same host and perhaps even using the same path. Since the line above is matching the TargetHostId and TargetDir that's one scenario that would lead to duplicates.chris.childerhose wrote:Now this fixes it but why does this command list all repositories versus per job -
$repo = (Get-VBRBackupRepository | ?{$_.HostId -eq $job.TargetHostId -and $_.Path -eq $job.TargetDir}).name
Honestly though, that feels like a pretty complex way to get repo information when you already have the job object right there. I'd suggest just deleting those two lines dealing with the repository completely and replacing it with the following much simpler solution:
Code: Select all
$jobOptions | Add-Member -MemberType NoteProperty -Name "Repository" -value $job.GetTargetRepository().Name