Quantcast
Channel: R&D Forums
Viewing all articles
Browse latest Browse all 9920

PowerShell • Re: move vms with exclusions script

$
0
0
Hi,

Yes, you would need to add VMs as new job objects to a target job and then update each of them with the exclusion data from the source job. An example for vSphere backup jobs:

Code:

$targetJob = Get-VBRJob -Name 'Backup Job 1'$sourceJob = Get-VBRJob -Name 'Backup Job 2'$objects = Get-VBRJobObject -Job $sourceJobforeach ($object in $objects) {  $entity = Find-VBRViEntity -Name $object.Name -Server pdcpmvtc02.dev.amust.local | where {$_.Reference -eq $object.Object.ObjectRef}  Add-VBRViJobObject -Job $targetJob -Entities $entity  $targetJob = Get-VBRJob -Name 'Backup Job 1'  $targetObject = Get-VBRJobObject -Job $targetJob -Name $object.Name | where {$_.Object.ObjectRef -eq $object.Object.ObjectRef}  $targetObject.Update($object.VssOptions, $object.DiskFilterInfo, $object.UpdateConfig, $object.Type)}
This script will loop through each of objects of a source job you want to move the vms from, add and then update each of them in the target job separately. I'm using a conjunction of object name and vm reference on the vSphere infrastructure to filter each vm to avoid dealing with duplicated names.

Let me know if it helps,
Oleg

Statistics: Posted by oleg.feoktistov — Dec 05, 2023 12:53 am



Viewing all articles
Browse latest Browse all 9920

Latest Images

Trending Articles



Latest Images