PowerShell script exchange
Post Reply
vizzzor
Lurker
Posts: 2
Liked: never
Joined: Apr 24, 2024 2:03 pm
Full Name: Alexey
Contact:

analog of Remove-VBRJobObject for Get-VBRComputerBackupJob

Post by vizzzor »

Hello,

I need to remove a server from an agent backup job using PowerShell, I tried to apply the same logic as for VM machine removing, but it does not work

Code: Select all

Get-VBRComputerBackupJob | Get-VBRJobObject -Name $target | Remove-VBRJobObject
according to documentation it should be possible by rewriting BackupObject using Set-VBRComputerBackupJob, but I thought maybe there is some more elegance way, something similar to VM removing
could you suggest me some method?

tnx
david.domask
Veeam Software
Posts: 1277
Liked: 331 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: analog of Remove-VBRJobObject for Get-VBRComputerBackupJob

Post by david.domask » 1 person likes this post

Hi Alexey, welcome to the forums.

You have the correct way, use Set-VBRComputerBackupJob for this and just rebuild an array of Discovered Computers or Protection Groups and pass them to the -BackupObject parameter.

Though the idea makes sense, it would be nice way to expand on the Agent cmdlet sets, so let's consider it an enhancement request for the Agent cmdlets, and use Set-VBRComputerBackupJob for now.
David Domask | Product Management: Principal Analyst
vizzzor
Lurker
Posts: 2
Liked: never
Joined: Apr 24, 2024 2:03 pm
Full Name: Alexey
Contact:

Re: analog of Remove-VBRJobObject for Get-VBRComputerBackupJob

Post by vizzzor »

That is how I solved it, in case someone has similar situation. Surprisingly Get-VBRJobObject was able to process Get-VBRComputerBackupJob output :)

Code: Select all

$target = "test"

$jobs = Get-VBRComputerBackupJob | Where-Object { $_ | Get-VBRJobObject -Name $target }

ForEach ($job in $jobs) {

    $content = $job.BackupObject| Where-Object { $_.Name -ne $target }
    Set-VBRComputerBackupJob -Job $job -BackupObject $content
}
david.domask
Veeam Software
Posts: 1277
Liked: 331 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: analog of Remove-VBRJobObject for Get-VBRComputerBackupJob

Post by david.domask » 1 person likes this post

Thanks for sharing your solution! And indeed a few of the cmdlets still interact like that and can lead to some rabbit holes like this, but you have the right way of addressing this :)
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests