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
public ServicePolicyEnable(objVcHostSystem: VcHostSystem, strServiceName: string, strServicePolicyState: "on" | "off"): boolean {
let blnReturn: boolean = this.ServicePolicyToggle(objVcHostSystem, strServiceName, "on");
return blnReturn;
}TypeScriptPublic Function: ServicePolicyDisable
public ServicePolicyDisable(objVcHostSystem: VcHostSystem, strServiceName: string, strServicePolicyState: "on" | "off"): boolean {
let blnReturn: boolean = this.ServicePolicyToggle(objVcHostSystem, strServiceName, "off");
return blnReturn;
}TypeScriptPrivate Function: ServicePolicyToggle
private ServicePolicyToggle(objVcHostSystem: VcHostSystem, strServiceName: string, strServicePolicyState: "on" | "off"): boolean {
try {
let objVcHostConfigManager: VcHostConfigManager = objVcHostSystem.configManager;
let objVcHostServiceSystem: VcHostServiceSystem = objVcHostConfigManager.serviceSystem;
let objVcHostService: VcHostService = this.ServiceGetByName(objVcHostServiceSystem, strServiceName);
if (objVcHostService.policy === "on" && strServicePolicyState === "off") {
objVcHostServiceSystem.updateServicePolicy(strServiceName, "off");
} else if (objVcHostService.policy === "off" && strServicePolicyState === "on") {
objVcHostServiceSystem.updateServicePolicy(strServiceName, "on");
}
return true;
}
catch (objException) {
return false;
}
}TypeScriptDiscover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
