Function: Wait for a vSphere Replication Task to Complete

by Simon Sparks · 4 February 2026

To use this function add it to the class library file named OrchestratorService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: OrchestratorService.ts

Description: Orchestrator Function to Wait for a vSphere Replication Task to Complete

Private Function: waitVRTaskEnd

private waitVRTaskEnd(objVRTask: VRTask): void {
    while (objVRTask != null) {

        let strName: string = objVRTask.name != null ? "'" + objVRTask.name + "' " : "";
        let strState: string = objVRTask.getState();

        if (strState == "success") {
            this.objLogger.info("Task " + strName + "succeeded");
            break;
        }
        else if (strState == "error") {
            throw "Task " + strName + "error: " + objVRTask.getErrotMessage();
        }
        else if (strState == "running") {
            if (objVRTask.getProgress() != null) {
                this.objLogger.info("Task " + strName + objVRTask.getProgress() + "%");
            }
            else {
                this.objLogger.info("Task " + strName + "in progress");
            }
        }
        else if (strState == "queued") {
            this.objLogger.info("Task " + strName + "is queued");
        }

        System.sleep(500);
    }

    if (objVRTask == null) {
        throw "VRTask Task is null";
    }
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like