Skip to content

adamswbrown/RVToolstoCSV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Export-MachineInfo PowerShell Function

Overview

The Export-MachineInfo function is designed to parse and export data from an Excel file generated by RVTools, which provides detailed data about VMWare environments. The primary use case is to extract detailed information about virtual machines (VMs) from various sheets within the Excel file, and export that information into individual CSV files for further analysis or processing. Each row in the "vInfo" sheet, representing a VM, will be exported as a separate CSV file, containing all of the relevant information from all tabs within the RVTools output.

Prerequisites

  • PowerShell: Ensure that PowerShell is installed on your system.
  • ImportExcel Module: This function utilizes the ImportExcel PowerShell module. Install it using the following PowerShell command:
    Install-Module -Name ImportExcel -Scope CurrentUser -Force

Parameters

Mandatory Parameters

  • ExcelFilePath: The full path to the RVTools Excel file that you wish to process.

Optional Parameters

  • OutputDir: The directory where the exported CSV files will be saved. If not specified, it defaults to "./Output".

  • VMIndex: The index (row number) of a specific VM in the "vInfo" sheet you wish to process. If not specified, all VMs will be processed.

  • ExcludeNoDataVMs: A switch parameter. If used, VMs that do not have additional data in other sheets will not be exported.

  • ExcludePoweredOff: A switch parameter. If used, VMs that are powered off will not be processed.

  • ExcludeTemplates: A switch parameter. If used, VM templates will not be processed.

  • ExcludeSRM: A switch parameter. If used, VMs that are Site Recovery Manager (SRM) placeholders will not be processed.

  • VerboseLogging: A switch parameter. If used, detailed logging will be displayed during processing.

Usage

Basic Usage

To process all VMs without exclusion and save CSV files to the default output directory ("./Output"):

Export-MachineInfo -ExcelFilePath "path_to_your_excel_file.xlsx"

Advanced Usage

To process a specific VM, exclude certain VMs, and specify an output directory:

Export-MachineInfo -ExcelFilePath "path_to_your_excel_file.xlsx" -VMIndex 3 -OutputDir "path_to_output_directory" -ExcludePoweredOff -ExcludeTemplates -ExcludeSRM -VerboseLogging

Examples of Usage

Example 1: Basic Usage

Export data for all VMs from the RVTools Excel file and save the CSV files to the default output directory ("./Output").

Export-MachineInfo -ExcelFilePath "C:\path\to\your\RVTools_output.xlsx"

Example 2: Specify Output Directory

Export data for all VMs and save the CSV files to a custom output directory.

Export-MachineInfo -ExcelFilePath "C:\path\to\your\RVTools_output.xlsx" -OutputDir "C:\custom\output\directory"

Example 3: Process a Specific VM

Export data only for the VM represented by the 3rd row in the "vInfo" sheet.

Export-MachineInfo -ExcelFilePath "C:\path\to\your\RVTools_output.xlsx" -VMIndex 3

Example 4: Exclude Specific VMs

Export data for all VMs, excluding those that are powered off, templates, or SRM placeholders.

Export-MachineInfo -ExcelFilePath "C:\path\to\your\RVTools_output.xlsx" -ExcludePoweredOff -ExcludeTemplates -ExcludeSRM

Example 5: Verbose Logging

Export data for all VMs with verbose logging enabled to view detailed processing logs in the console.

Export-MachineInfo -ExcelFilePath "C:\path\to\your\RVTools_output.xlsx" -VerboseLogging

Example 6: Combine Parameters

Export data only for the VM represented by the 5th row in the "vInfo" sheet, exclude it if it’s powered off or a template, save the CSV to a custom output directory, and enable verbose logging.

Export-MachineInfo -ExcelFilePath "C:\path\to\your\RVTools_output.xlsx" -VMIndex 5 -OutputDir "C:\custom\output\directory" -ExcludePoweredOff -ExcludeTemplates -VerboseLogging

Notes

  • Ensure to adjust the file paths in the examples as per your system.
  • Ensure that the RVTools Excel file is not open in Excel during the script execution to avoid file access issues.

Detailed Workflow

  1. Import Excel Data: All sheets from the specified Excel file are imported into PowerShell using the ImportExcel module.

  2. Initial Analysis: Before processing VMs, the function analyzes and logs the total VM count and potential exclusions based on provided parameters.

  3. Processing VMs: VMs from the "vInfo" sheet are processed based on provided parameters and exclusion switches. For each VM:

    • Additional data from other sheets is matched and appended to the VM’s data object.
    • If no additional data is found and -ExcludeNoDataVMs is used, the VM may be skipped.
    • The combined data is exported as a CSV file named after the VM.
  4. Logging: Progress and issues are logged to the console. Verbose logging can be enabled with -VerboseLogging for detailed processing logs.

Notes

  • Always ensure to validate the exported data.
  • Test the function in a non-production environment first.
  • Ensure to have backups of your critical data to prevent any accidental data loss.

Support and Contribution

For support, issues, or enhancement suggestions, please open an issue on GitHub. Contributions to enhance the function are welcome. Please fork the repository and submit a pull request with your changes.

About

Converts to RVTools Output to CSV Outputs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published