Learning Objectives
By the end of this article, you will:
Automate export of VMware inventory and reports to CSV/Excel using PowerCLI.
Use Python to parse, filter, and visualize VMware report data.
Build a basic VM inventory dashboard in Python.
Understand workflow visualization with an diagram.
My Personal Repository on GitHub
VMware Repository on GitHub
Prerequisites
Completed Articles 1–4.
PowerCLI, Python, and the Python modules pandas and matplotlib are installed: pip install pandas matplotlib
VMware vCenter or ESXi access.
1. Exporting VM Inventory with PowerCLI
Let’s create a PowerShell script that exports VM info (Name, PowerState, Guest OS, IP, CPU, Memory) to CSV.
Save as export_vm_inventory.ps1:
# Import PowerCLIImport-Module VMware.PowerCLI# Connect to vCenter (update details)Connect-VIServer -Server <vcenter-address> -User <username> -Password <password># Export VM dataGet-VM | Select-Object Name, PowerState, @{N=”GuestOS”;E={$_.Guest.OSFullName}}, @{N=”IPAddress”;E={$_.Guest.IPAddress -join ‘, ‘}}, NumCpu, MemoryGB | Export-Csv -Path C:Tempvm_inventory.csv -NoTypeInformationDisconnect-VIServer -Server * -Confirm:$false
2. Reading and Visualizing the CSV with Python
The following Python script reads your exported CSV and visualizes basic VM stats.
import pandas as pdimport matplotlib.pyplot as plt# Load the CSV filedf = pd.read_csv(r”C:Tempvm_inventory.csv”)# Print the first few rowsprint(df.head())# Count VMs by PowerStatestate_counts = df[‘PowerState’].value_counts()# Plot PowerState distributionplt.figure(figsize=(6,4))state_counts.plot(kind=’bar’)plt.title(‘VM Power State Distribution’)plt.xlabel(‘Power State’)plt.ylabel(‘Number of VMs’)plt.tight_layout()plt.show()# Group by GuestOSos_counts = df[‘GuestOS’].value_counts().head(10)plt.figure(figsize=(8,4))os_counts.plot(kind=’barh’)plt.title(‘Top 10 Guest OS Types’)plt.xlabel(‘Number of VMs’)plt.tight_layout()plt.show()
3. Diagram: Reporting and Visualization Flow
4. Advanced: Exporting Directly to Excel
You can also use PowerCLI to export reports in Excel format with Export-Excel from the ImportExcel PowerShell module.
# Install the module (run once)Install-Module -Name ImportExcel -Scope CurrentUser# Export to ExcelGet-VM | Select-Object Name, PowerState, NumCpu, MemoryGB | Export-Excel -Path C:Tempvm_inventory.xlsx -AutoSize
Now, your Python scripts can also read .xlsx files using pandas.read_excel().
5. Troubleshooting Tips
If you see file permission errors, confirm you have write access to the target folder.
For Python plotting errors, ensure you installed matplotlib and pandas.
Large vCenters may export thousands of rows; filter in PowerCLI or Python for smaller data sets.
6. Further Reading
VMware PowerCLI Documentation
pandas Documentation
matplotlib Documentation
ImportExcel PowerShell Module
7. Conclusion and Next Steps
You have learned to export VMware inventory to CSV/Excel and create basic data visualizations with Python.This capability is a foundation for dashboards, audit reports, and capacity analysis for your virtual infrastructure.
Next up: In Article 6, you will add error handling and logging to your scripts, with practical examples including integration with Aria for Logs.
Next PostHandling Errors and Adding Logging for VMware Automation (PowerCLI & Python)Learning Objectives By the end of this article, you will: Implement error handling in both PowerCLI and Python scripts. Add log file creation for task auditing and troubleshooting. Integrate VMware…
The post Exporting and Visualizing VMware Reports with PowerCLI and Python appeared first on Digital Thought Disruption.

