Share
1

🔍 Generating CSV Reports for Managed VMs in VMware Aria Automation

by Mayank Goyal · 8 Apr 2025

v2.0 updates

  • Replaced Get Operation workflow with Get Operations with Pagination workflow to handle all (more than 200) machines.
  • Option to generate a Markdown .md file for better visibility in Orchestrator along with .csv.
  • The Report now includes IP Address of the machine as well.

Get the latest v2.0 package here.


Intro

When managing hybrid and multi-cloud environments, having quick visibility into all deployed virtual machines is essential. Whether it’s for inventory management, audits, or simply keeping track of resource usage, an automated CSV report can be incredibly useful.

In this blog post, we’ll walk through how to generate a CSV report listing all managed VMs in VMware Aria Automation, including key details like power state, hostname, origin, resource size, and ownership. We’ll also cover how to save the generated CSV as a resource element in Aria Orchestrator.

🧩 Step 1: Use the GET Operation Library Workflow to Query Resources

We start by using the Library > vRealize Automation 8.x and Cloud Services > Sample Rest Operations > Get Operation workflow to fetch all deployed and onboarded machine resources via Aria Automation APIs.

Here’s the API endpoint we used:

HTTP
GET /deployment/api/resources?size=1000&sort=createdAt%2CDESC&search=&expand=deployment%2Cproject%2CinprogressRequests%2CcurrentRequest&resourceRefreshStrategy=ASYNC&origin=DEPLOYED%2CONBOARDED%2CMIGRATED&resourceTypes=Cloud.Machine%2CCloud.vSphere.Machine%2CCloud.AWS.EC2.Instance%2CCloud.Azure.Machine%2CCloud.GCP.Machine%2CCloud.vcd.Machine%2CIdem.AWS.EC2.INSTANCE%2CIdem.GCP.COMPUTE.INSTANCE&apiVersion=2020-08-25

This query returns up to 1000 machine resources sorted by creation date. It includes all major cloud types (vSphere, AWS, Azure, GCP, and more), all deployed, migrated and onboarded.

🧪 Step 2: Parse the API Response and Build the CSV

Once the API returns the machine data as a JSON string (machinesAsString), we parse it and extract key properties for each VM:

JavaScript
var allMachines = JSON.parse(machinesAsString).content;

var reportCSV = "Name,Power status,Hostname,Origin,Total memory (MB),CPU Count,Creation Date,Owned by,Parent Deployment\r\n";

for each(var machine in allMachines){
    if(machine.name)
        var machineName = machine.name;
    if(machine.properties && machine.properties.powerState)
        var powerStatus = machine.properties.powerState;
    if(machine.properties && machine.properties.hostName)
        var hostname = machine.properties.hostName;  
    if(machine.origin)
        var origin = machine.origin;    
    if(machine.properties && machine.properties.totalMemoryMB)
        var totalMemoryMB = machine.properties.totalMemoryMB; 
    if(machine.properties && machine.properties.cpuCount)
        var cpuCount = machine.properties.cpuCount; 
    if(machine.createdAt)
        var creationDate = machine.createdAt;
    if(machine.deployment && machine.deployment.ownedBy)
        var owner = machine.deployment.ownedBy;
    if(machine.deployment && machine.deployment.name)
        var parentDeploymentName = machine.deployment.name;

    reportCSV += (machineName + "," + powerStatus + "," + hostname + ","  + origin + ","  + totalMemoryMB + ","   + cpuCount + "," + creationDate  + "," + owner+ "," + parentDeploymentName+"\r\n");
}
System.log(reportCSV);

This produces a neatly formatted CSV string with the following columns:

  • Name
  • Power status
  • Hostname
  • Origin (Deployed/Onboarded/Migrated)
  • Memory (MB)
  • CPU Count
  • Creation Date
  • Owned by (User)
  • Parent Deployment

💾 Step 3: Save the Report as a Resource Element

To persist this report in Aria Automation Orchestrator, we save the CSV as a resource element. If the resource already exists, we update it; otherwise, we create it.

JavaScript
var resourcePath = "CloudBlogger/vRA/vRA_Machine_details.csv";
try {
	resource = System.getModule("com.vmware.pso.util").getResourceElementByFullPath(resourcePath);
} catch (e) {
	System.warn(e);
}

if (!resource) {
	var categoryPath, resourceName;
	var delimiterIndex = resourcePath.lastIndexOf("/");

	if (delimiterIndex === -1) {
		throw "Failed to parse resource element path for creating a new resource element";
	}
	
	categoryPath = resourcePath.substr(0, delimiterIndex);
	resourceName = resourcePath.substr(delimiterIndex + 1);
	
	resource = Server.createResourceElement(categoryPath, resourceName, null, "text/csv");
}

resourceMime = new MimeAttachment();
resourceMime.name = resource.name;
resourceMime.mimeType = "text/csv";
resourceMime.content = reportCSV;
resource.setContentFromMimeAttachment(resourceMime);

System.log("Resource element at \""+resourcePath+"\" updated successfully.");

After execution, the resource element can be downloaded or accessed directly from the vRO interface at this location CloudBlogger/vRA/vRA_Machine_details.csv.

📝 Sample CSV data

NamePower statusHostnameOriginTotal memory (MB)CPU CountCreation DateOwned byParent Deployment
web-server-01ONweb01.corp.localDEPLOYED409622025-04-06T10:15:30Zjdoe@example.comWebApp Deployment
db-server-01OFFdb01.corp.localONBOARDED819242025-03-28T08:45:12Zasmith@example.comDBCluster Deployment
test-machine-03ONtest03.lab.localMIGRATED204812025-04-01T14:30:00Ztestuser@example.comTestStack Deployment
linux-vm-12ONlinux12.dev.localDEPLOYED614422025-04-07T06:22:17Zdevteam@example.comLinuxBuild Deployment
win-vm-21SUSPENDEDwin21.prod.localDEPLOYED409622025-03-30T11:10:45Zprodadmin@example.comWindowsProd Deployment

📦 Download the Workflow Package

Want to try it out yourself? You can download the complete vRO workflow package from our GitHub repo:

👉 Download in.co.cloudblogger.generateCsvVraMachines.package

📌 How to install:

  1. Navigate to Assests > Packages
  2. Click on Import button
  3. Upload the .package file
  4. Verify the workflow (Generate CSV of vRA Managed Machine details [Approach 2]) is imported successfully
  5. In the workflow, set the vraHost variable as required.

You’re all set to automate your VM reporting! 🧙‍♂️

🚀 Next Steps

Now that we’ve built the core automation for generating VM reports in CSV format, let’s look at how you can take it to the next level:

📆 Schedule the Workflow to Run Daily or Weekly

Use vRO’s built-in scheduling capabilities to automate report generation:

  • Go to Workflow > Click on Schedule button
  • Create a new schedule for your CSV generation workflow
  • Choose the frequency (daily, weekly, monthly)

Tip: Use different resource element names (e.g., include timestamps) if you want to keep historical versions.

📧 Email the Report to Stakeholders Automatically

Once the report is generated, you can email it as an attachment using the Send Notification workflow or a custom SMTP configuration. Here’s a basic outline:

JavaScript
System.debug("Adding CSV attachment");

var objMimeAttachment;
objMimeAttachment = new MimeAttachment();
objMimeAttachment.name = "vRA_Machines_Report.csv";
objMimeAttachment.content = reportCSV; // the generated CSV content here
var message = new EmailMessage();
message.smtpHost = "smtp.example.com";
message.fromAddress = "noreply@example.com";
message.subject = "Daily VM Report - " + new Date().toLocaleDateString();
message.addMimePart("Workflow Report Generation", "text/html");
message.addMimePart(objMimeAttachment, "text/x-csv");
message.toAddress = "ops-team@example.com";

System.debug("Sending email to \"" + message.toAddress + "\"");nder<br>    emailAddress,           // Recipient<br>    subject,<br>    body,<br>    attachment<br>);<br></code>

Make sure your SMTP settings are properly configured in vRO’s system settings.

💡 Enhance the Report with Additional Fields

Want deeper insights? Here are some useful fields you can include in future iterations:

  • Cost data (estimated or actual) via Pricing Cards
  • Tags and customProperties
  • Storage size used or disk count
  • Network details like IP addresses or NSX security groups
  • Project and Business Group info

💬 Have questions or want to add filtering by project or owner? Drop them in the comments or reach out—I’m happy to help!


Discover more from Cloud Blogger

Subscribe to get the latest posts sent to your email.

You may also like