Function: vCenter Host System Maintenance Mode

by Simon Sparks · 5 January 2026

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

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

Filename: PluginVCHostSystemService.ts

Function: MaintenanceModeStatus


publicMaintenanceModeStatus(objVcHostSystem:VcHostSystem):boolean{

letobjVcHostRuntimeInfo:VcHostRuntimeInfo=objVcHostSystem.runtime;

letblnInMaintenanceMode:boolean=objVcHostRuntimeInfo.inMaintenanceMode;

returnblnInMaintenanceMode
}
TypeScript

Function: MaintenanceModeEnter

publicMaintenanceModeEnter(objVcHostSystem:VcHostSystem,blnEvacuatePoweredOffVms:boolean=true,intTimeoutSeconds:number=30):void{

intTimeoutSeconds=intTimeoutSeconds*1000;

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

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

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

this.WaitForVcTaskEnd(objVcTask,2);
}
TypeScript

Function: MaintenanceModeExit

publicMaintenanceModeExit(objVcHostSystem:VcHostSystem):void{

letintTimeout:number=300;

letobjVcTask:VcTask=objVcHostSystem.exitMaintenanceMode_Task(intTimeout);

this.WaitForVcTaskEnd(objVcTask,2);
}
TypeScript

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like