I have an issue where a replication job schedule is quite frequent and often runs again before the merge of the previous schedule has completed, which causes us to have orphaned checkpoints all over the place. I am trying to implement a pre/post-script to check if the particular VM is currently merging and postpones the job until next schedule if it is. I toyed around with trying to disable the job in a pre-script if it is merging and re-enabling it, but since the job gets disabled and doesn't finish I can't re-enable it in the post-script. I'm wondering if there is a better way to do this than using an if? (maybe a while loop?)? Appreciate the assistance.
Code: Select all
$VM = Get-SCVirtualMachine -name VMName
$Job = Get-VBRJob Replica-Job
if ($VM.status = "Merging"){
Disable-VBRJob $Job
}