Orchestrator Function: vCenter Virtual Machine Export Ovf Properties To Csv

by Simon Sparks · 13 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: VcVirtualMachineExportOvfPropertiesToCsv

publicVcVirtualMachineExportOvfPropertiesToCsv(arrVcVirtualMachine:VcVirtualMachine[]):string{

letarrLine:string[]= [];
arrLine.push("vmName,ovfKey,value,defaultValue,category,type");

arrVcVirtualMachine.forEach((objVcVirtualMachine:VcVirtualMachine):void=>{

letobjVcVirtualMachineConfigInfo:VcVirtualMachineConfigInfo=objVcVirtualMachine.config;

letobjVcVmConfigInfo:VcVmConfigInfo=objVcVirtualMachineConfigInfo.vAppConfig;

letarrVcVAppPropertyInfo:VcVAppPropertyInfo[]=objVcVmConfigInfo.property;

arrVcVAppPropertyInfo.forEach((objVcVAppPropertyInfo:VcVAppPropertyInfo):void=>{

letstrOvfKey:string="";

if (objVcVAppPropertyInfo.classId&&objVcVAppPropertyInfo.instanceId){
strOvfKey=objVcVAppPropertyInfo.classId+"."+objVcVAppPropertyInfo.id+"."+objVcVAppPropertyInfo.instanceId;
}elseif (objVcVAppPropertyInfo.classId){
strOvfKey=objVcVAppPropertyInfo.classId+"."+objVcVAppPropertyInfo.id;
}else{
strOvfKey=objVcVAppPropertyInfo.id;
}

letstrValue:string=objVcVAppPropertyInfo.value||"";
letstrDefaultValue:string=objVcVAppPropertyInfo.defaultValue||"";
letstrCategory:string=objVcVAppPropertyInfo.category||"";
letstrType:string=objVcVAppPropertyInfo.type||"";

strValue=strValue.replace(/""/g,"\"");

strOvfKey=Utilities.escapeValuesForCsv(strOvfKey);
strValue=Utilities.escapeValuesForCsv(strValue);
strDefaultValue=Utilities.escapeValuesForCsv(strDefaultValue);
strCategory=Utilities.escapeValuesForCsv(strCategory);
strType=Utilities.escapeValuesForCsv(strType);

arrLine.push(objVcVirtualMachine.name+","+strOvfKey+","+strValue+","+strDefaultValue+","+strCategory+","+strType);

});

});

returnarrLine.join("\n");
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like