To use this function add it to the class library file named PluginVCHostSystemService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: PluginVCHostSystemService.ts
Public Function: ServicePolicyEnable
publicServicePolicyEnable(objVcHostSystem:VcHostSystem,strServiceName:string,strServicePolicyState:"on"|"off"):boolean{
letblnReturn:boolean=this.ServicePolicyToggle(objVcHostSystem,strServiceName,"on");
returnblnReturn;
}TypeScriptPublic Function: ServicePolicyDisable
publicServicePolicyDisable(objVcHostSystem:VcHostSystem,strServiceName:string,strServicePolicyState:"on"|"off"):boolean{
letblnReturn:boolean=this.ServicePolicyToggle(objVcHostSystem,strServiceName,"off");
returnblnReturn;
}TypeScriptPrivate Function: ServicePolicyToggle
privateServicePolicyToggle(objVcHostSystem:VcHostSystem,strServiceName:string,strServicePolicyState:"on"|"off"):boolean{
try{
letobjVcHostConfigManager:VcHostConfigManager=objVcHostSystem.configManager;
letobjVcHostServiceSystem:VcHostServiceSystem=objVcHostConfigManager.serviceSystem;
letobjVcHostService:VcHostService=this.ServiceGetByName(objVcHostServiceSystem,strServiceName);
if (objVcHostService.policy==="on"&&strServicePolicyState==="off"){
objVcHostServiceSystem.updateServicePolicy(strServiceName,"off");
}elseif (objVcHostService.policy==="off"&&strServicePolicyState==="on"){
objVcHostServiceSystem.updateServicePolicy(strServiceName,"on");
}
returntrue;
}
catch (objException){
returnfalse;
}
}TypeScriptDiscover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
