Orchestrator Function: vCenter Host System Maintenance Mode

by Simon Sparks · 5 January 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: VcHostSystemMaintenanceModeStatus


publicVcHostSystemMaintenanceModeStatus(objVcHostSystem:VcHostSystem):boolean{

letobjVcHostRuntimeInfo:VcHostRuntimeInfo=objVcHostSystem.runtime;

letblnInMaintenanceMode:boolean=objVcHostRuntimeInfo.inMaintenanceMode;

returnblnInMaintenanceMode
}

Function: VcHostSystemMaintenanceModeEnter

publicVcHostSystemMaintenanceModeEnter(objVcHostSystem:VcHostSystem):void{

letblnEvacuatePoweredOffVms:boolean=true;

letintTimeout:number=300;

letobjVcVsanHostDecommissionMode:VcVsanHostDecommissionMode=newVcVsanHostDecommissionMode();
objVcVsanHostDecommissionMode.objectAction="noAction";

letobjVcHostMaintenanceSpec:VcHostMaintenanceSpec=newVcHostMaintenanceSpec();
objVcHostMaintenanceSpec.vsanMode=objVcVsanHostDecommissionMode;

letobjVcTask:VcTask=objVcHostSystem.enterMaintenanceMode_Task(intTimeout,blnEvacuatePoweredOffVms,objVcHostMaintenanceSpec);

this.WaitForVcTaskEnd(objVcTask,2);
}

Function: VcHostSystemMaintenanceModeExit

publicVcHostSystemMaintenanceModeExit(objVcHostSystem:VcHostSystem):void{

letintTimeout:number=300;

letobjVcTask:VcTask=objVcHostSystem.exitMaintenanceMode_Task(intTimeout);

this.WaitForVcTaskEnd(objVcTask,2);
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like