-
- Influencer
- Posts: 22
- Liked: 1 time
- Joined: Oct 12, 2016 3:17 pm
- Full Name: Nan Zhang
- Contact:
Determine if replication job has VM replica mapping
I am looking for a way to find if a replication job has VM replica mapping set. I am using VBR 9.0.
I am aware of the option $replicajob.ViReplicaTargetOptions.UseVmMapping. But this just checks if the VM seeding is enabled but it doesn't tell if a replica VM is mapped.
I am aware of the option $replicajob.ViReplicaTargetOptions.UseVmMapping. But this just checks if the VM seeding is enabled but it doesn't tell if a replica VM is mapped.
-
- VP, Product Management
- Posts: 27371
- Liked: 2799 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Determine if replication job has VM replica mapping
Can you please tell us a bit more about your use case? This would help us to give a better answer to your question.
-
- Influencer
- Posts: 22
- Liked: 1 time
- Joined: Oct 12, 2016 3:17 pm
- Full Name: Nan Zhang
- Contact:
Re: Determine if replication job has VM replica mapping
At the moment we have three hundreds or so replication jobs created for a datacentere migration move. We want to use VM mapping once there is a replica is in place. But what I found is that even if the 'UseVMMapping' option is enabled it doesn't always mean that a source VM is mapped to its replica (Under replication job property, Seeding -> Replica Mapping), so what I wanted to do is identify those replication jobs that do not have VM mapping (ie "Replica VM" under the Seeding showing "No Mapping").
Hope this is clear.
Hope this is clear.
-
- VP, Product Management
- Posts: 27371
- Liked: 2799 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Determine if replication job has VM replica mapping
Ok, thanks! Cannot comment on how to achieve that via PS (not an expert), but you can try this report to see all the settings for replication jobs > Job Configuration Dump
-
- Influencer
- Posts: 22
- Liked: 1 time
- Joined: Oct 12, 2016 3:17 pm
- Full Name: Nan Zhang
- Contact:
Re: Determine if replication job has VM replica mapping
Thanks for the suggestion. The report does have the VM mapping information for these replication jobs but unfortunately it spans over 1000+ pages so it isn't very practical.
Without a way to extract this information via PS, the best option is to try to remap the VM regardless where it is needed or not.
Without a way to extract this information via PS, the best option is to try to remap the VM regardless where it is needed or not.
-
- VP, Product Management
- Posts: 6035
- Liked: 2860 times
- Joined: Jun 05, 2009 12:57 pm
- Full Name: Tom Sightler
- Contact:
Re: Determine if replication job has VM replica mapping
While I could not find any obvious way to do this with the native cmdlets/objects, here's some details for some internal functions that might help you.
This function will return an array with all mapped object for a given job ID:
This function will return the individual mapped object for any given combination of job and object ID:
As long as the VMs are added to the job individually rather than via some container object like a folder or datastore, then something like this could do what you want (just an example but easy to extend):
This function will return an array with all mapped object for a given job ID:
Code: Select all
[Veeam.Backup.Core.CReplicaMapping]::Get(jobId)
Code: Select all
[Veeam.Backup.Core.CReplicaMapping]::Find(jobId, objectId)
Code: Select all
$jobName = "<Job_Name>"
$job = Get-VBRJob -Name $jobName
$jobObjs = Get-VBRJobObject -Job $job
foreach ($jobObj in $jobObjs) {
$vmmap = $null
$vmmap = [Veeam.Backup.Core.CReplicaMapping]::Find($job.id, $jobObj.ObjectId)
if ($vmmap) {
write-host -ForegroundColor Green "VM $($jobObj.Name) is mapped to VM $($vmmap.MappedObj)"
} else {
write-host -ForegroundColor Yellow "WARNING - VM $($jobObj.Name) is NOT mapped!"
}
}
-
- Influencer
- Posts: 22
- Liked: 1 time
- Joined: Oct 12, 2016 3:17 pm
- Full Name: Nan Zhang
- Contact:
Re: Determine if replication job has VM replica mapping
Thank you!
This code does exactly what I am looking for. I just had to parameterized it so I can use it with a foreach statement, like so.
The full get-MappedVM.ps1 script is as below:
This code does exactly what I am looking for. I just had to parameterized it so I can use it with a foreach statement, like so.
Code: Select all
get-vbrjob | ? { $_.jobtype -eq 'replica' } | % { .\get-MappedVM.ps1 -jobname $_.name }
Code: Select all
param (
[Parameter(Mandatory=$true)]
$jobName
)
$job = Get-VBRJob -Name $jobName
$jobObjs = Get-VBRJobObject -Job $job
foreach ($jobObj in $jobObjs) {
$vmmap = $null
$vmmap = [Veeam.Backup.Core.CReplicaMapping]::Find($job.id, $jobObj.ObjectId)
if ($vmmap) {
$sourceVMString = "[{0,24}]" -f $jobObj.name
write-host -ForegroundColor Green "VM $sourceVMstring is mapped to VM $($vmmap.MappedObj)"
} else {
write-host -ForegroundColor Yellow "WARNING - VM $($jobObj.Name) is NOT mapped!"
}
}
-
- Lurker
- Posts: 1
- Liked: never
- Joined: Feb 02, 2024 4:24 pm
- Full Name: tamosi
- Contact:
Re: Determine if replication job has VM replica mapping
Hello,
Sorry to reply on an old thread, does anyone know how to do it when I have a folder or a host in the replica job ?
thanks in advance for your help.
Sorry to reply on an old thread, does anyone know how to do it when I have a folder or a host in the replica job ?
thanks in advance for your help.
Who is online
Users browsing this forum: No registered users and 21 guests