RVTools: Parse Multiple Outputs Using Powershell

If you haven’t used RVTools before, I’d definitely suggest taking a look. In case you’re one of the few that has not used it, it’s a quick tool to generate a point-in-time report of the inventory/configuration/health of a vSphere environment. While it’s one of the best tools out there for a quick and dirty report of an environment, the challenge I often face is that it outputs too much data. The other challenge I’ve faced is that it’s incredibly difficult to combine and analyze data from multiple outputs.

I created a PowerShell script to help with this. The end result is a PowerShell object that can be consumed in any way you like. In a future post, I’ll show how to take this output and create a new Excel spreadsheet.

The image below is an example of what the script below generates.

Example Output

As an FYI, we’ll need to install the ImportExcel module in order to parse the excel file. If you want more information, check out the GitHub repository for ImportExcel.

To run this script, at a minimum, you’ll need to modify the $spreadsheetdir variable to point to a directory that contains your RVTools outputs. This is a parameter, so it can be done by adding the -spreadsheetdir "[path to my RVTools directory]" if you like, or just feel free to modify the script.

Lines 12-45
Define column headers to be pulled for each spreadsheet

Line 50
Get the contents of the spreadsheet directory

Line 54
Loop through each spreadsheet in the spreadsheet directory

Lines 58
Get a distinct list of all clusters in the particular RVTools file. This will allow us to present the results one cluster at a time

Lines 68-82
Import the properties defined in lines 10-44 from the vInfo, vHost, and vDisk worksheet for later consumption

Lines 84-101
Do some math/formatting/voodoo to convert the values from RVTools into something useful

Lines 63,64 and 103-110
Take values from RVTools and calculations (from lines 84-101) and put them into a custom PowerShell object.

You can find the script in the public GitHub repository I keep all of the scripts for this site in:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright VirtJunkie.com ยฉ 2024