Function: vCenter Host System Firewall Ruleset Toggle

by Simon Sparks · 2 February 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

Public Function: FirewallRulesetEnable

publicFirewallRulesetEnable(objVcHostSystem:VcHostSystem,strRulesetName:string):boolean{

letblnResult:boolean=this.FirewallRulesetToggle(objVcHostSystem,strRulesetName,"Enable");

returnblnResult;
}

Public Function: FirewallRulesetDisable

publicFirewallRulesetDisable(objVcHostSystem:VcHostSystem,strRulesetName:string):boolean{

letblnResult:boolean=this.FirewallRulesetToggle(objVcHostSystem,strRulesetName,"Disable");

returnblnResult;
}

Private Function: FirewallRulesetToggle

privateFirewallRulesetToggle(objVcHostSystem:VcHostSystem,strRulesetName:string,strAction:"Enable"|"Disable"):boolean{

try{
letobjVcHostConfigManager:VcHostConfigManager=objVcHostSystem.configManager;

letobjVcHostFirewallSystem:VcHostFirewallSystem=objVcHostConfigManager.firewallSystem;

this.objLogger.info(`Attempting to${strAction} Firewall Ruleset on vCenter Host: '${objVcHostSystem.name}'...`);

if (strAction==="Enable"){
objVcHostFirewallSystem.enableRuleset(strRulesetName);
}
elseif (strAction==="Disable"){
objVcHostFirewallSystem.disableRuleset(strRulesetName);
}

this.objLogger.info(`Succesfully${strAction}d Firewall Ruleset on vCenter Host: '${objVcHostSystem.name}'.`);

returntrue;
}
catch (objException){
this.objLogger.info(`Failed to${strAction} Firewall Ruleset on vCenter Host: '${objVcHostSystem.name}'.`);

returnfalse;
}
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like