Orchestrator Function: vCenter Virtual Machine Consolidate Virtual Disks

by Simon Sparks · 2 February 2026

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

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

Filename: vCenterServerService.ts

Function: VcVirtualMachineConsolidateVcVirtualDisks

publicVcVirtualMachineConsolidateVcVirtualDisks(objVcVirtualMachine:VcVirtualMachine):void{

try{
letobjVcTask:VcTask=objVcVirtualMachine.consolidateVMDisks_Task();

this.WaitForVcTaskEnd(objVcTask,2);
}catch (objException){

Utilities.logException(objException,this.objLogger,"VcVirtualMachineConsolidateVcVirtualDisks");

if (objExceptioninstanceofVcFileFault){
this.objLogger.error(`Thrown if if there is a problem accessing the virtual machine's files for this operation. Typically a more specific fault FileLocked is thrown.`);
}
elseif (objExceptioninstanceofVcInvalidState){
this.objLogger.error(`Thrown if the operation cannot be performed because of the virtual machine's current state. For example, if the virtual machine configuration information is not available.`);
}
elseif (objExceptioninstanceofVcRuntimeFault){
this.objLogger.error(`Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.`);
}
elseif (objExceptioninstanceofVcTaskInProgress){
this.objLogger.error(`Thrown if the virtual machine is busy.`);
}
elseif (objExceptioninstanceofVcVmConfigFault){
this.objLogger.error(`Thrown if a virtual machine configuration issue prevents the estimation.Typically, a more specific fault is thrown.`);
}
}
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like