Link to home
Start Free TrialLog in
Avatar of patron
patronFlag for India

asked on

VMware Health Report

Need to automate few reports in separate excel sheet
  • VMware License utilization report
  • VMware Performance reports
  • VMware Health reports
  • Storage Capacity Report
which can be sent weekly /monthly on email

Please help for script to be used  for above requirements
Avatar of Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Andrew Hancock (VMware vExpert PRO / EE Fellow/British Beekeeper)
Flag of United Kingdom of Great Britain and Northern Ireland image

Does it have to be a script because RVtools will do all that.
Avatar of patron

ASKER

Actually RVTool provide more but we are looking for ..

VMware License utilization report - Not available in RVTool extract
VMware Performance reports -for CPU,RAM,STORAGE,NETWORK AND SLOT AVAILABILITY
VMware Health reports - CURRENT STATUS  
Storage Capacity Report -

Can we get this all in a customized format or if RVTool can be customized and automated with email reporting?
Performance will not be available because RVTools is an information gathering tool, not Perfomance monitoring.

You could look at which was originally sort of called VMware Daily Health Check

https://github.com/alanrenouf/vCheck-vSphere
Avatar of patron

ASKER

Thanks Andrew , did used it but we are looking for limited as requested information to be shared with Customer in Excel format
Avatar of patron

ASKER

able to achieve automation for data extracted by RVTools ,quite good , was looking if we can export the vcheck info into excel like it is working here with RVTool
# =============================================================================================================
# Script:    RVToolsMergeExcelFiles.ps1
# Version:   1.0
# Date:      February, 2018
# By:        Rob de Veij
# =============================================================================================================

<#
.SYNOPSIS
With this script you can merge two RVTools export xlsx files into one xlsx file
	
.DESCRIPTION
With this script you can merge two RVTools export xlsx files into one xlsx file
This script must be started on a Windows machine where Excel is installed!

.PARAMETER InputFile1
Path and Name of the first xlsx file

.PARAMETER InputFile2
Path and Name of the first xlsx file

.PARAMETER OutputFile
Path and Name of the output xlsx file


.EXAMPLE
 .\RVToolsMergeExcelFiles.ps1 -InputFile1 C:\temp\AAA.xlsx -InputFile2 C:\temp\BBB.xlsx -OutputFile C:\temp\CCC.xlsx

Script will first copy inputfile 1 to outputfile and after this will add inputfile 2 data to outputfile

#>

[CmdletBinding()]
Param
(
    [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$InputFile1,
    [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$InputFile2,
	[Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$OutputFile
)


#################
Function Finalize
#################
{
    ## close all object references
    if($Excel2 -ne $null)
    {
        $Excel2.quit()
        if($Worksheet2 -ne $null) { Release-Ref($Worksheet2) | Out-Null }
        if($Workbook2  -ne $null) { Release-Ref($Workbook2)  | Out-Null }
        Release-Ref($Excel2) | Out-Null
    }
	
    if($Excel3 -ne $null)    
    {
        $Excel3.quit()
        if($Worksheet3 -ne $null) { Release-Ref($Worksheet3) | Out-Null }
        if($Workbook3  -ne $null) { Release-Ref($Workbook3)  | Out-Null }
        Release-Ref($Excel3) | Out-Null
    }
}


###########################
Function Release-Ref ($ref)
########################### 
{
    ([System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$ref) -gt 0)
    [System.GC]::Collect()
    [System.GC]::WaitForPendingFinalizers()
}


#############################
# Check input file parameters
#############################
if((Test-Path $InputFile1) -eq $false)
{
	Write-Host "Input file 1 $InputFile1 not found!" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
    exit 1
}
$InputFile1 = (Get-ChildItem $InputFile1).FullName

if((Test-Path $InputFile2) -eq $false)
{
	Write-Host "Input file 2 $InputFile2 not found!" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
    exit 1
}
$InputFile2 = (Get-ChildItem $InputFile2).FullName


############################################
# Ouput file name must have a xlsx extension
############################################
if(($OutputFile.EndsWith(".xlsx")) -eq $false)
{
	Write-Host "Output file name must be an .xlsx file!" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
    exit 1
}
"" | Out-File $OutputFile
$OutputFile = (Get-ChildItem $OutputFile).FullName


################################################################
# Output file can not be the same file as one of the input files
################################################################
if(($InputFile1 -eq $OutputFile) -or ($InputFile2 -eq $OutputFile))
{
	Write-Host "Output file can not be the same file as one of the input files!" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
    exit 1
}


#####################################################
# Create output file. Copy Inputfile 1 to output file
#####################################################
try
{
	Copy-Item $InputFile1 -Destination $OutputFile -Force -ErrorAction Stop
}
catch
{
	Write-Host "Can not create output file $OutputFile" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
    exit 1
}


###################
# Open input file 2
###################
try
{
	$Excel2 = New-Object -ComObject excel.application
	$Excel2.visible = $false
	$Workbook2 = $excel2.Workbooks.open($InputFile2)
}
catch
{
	Write-Host "Can not open second input file $InputFile2" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
	finalize
    exit 1
}
	

##################
# Open output file
##################
try
{
	$Excel3 = New-Object -ComObject excel.application
	$Excel3.visible = $false
	$Workbook3 = $excel3.Workbooks.open($OutputFile)
}
catch
{
	Write-Host "Can not open output file $OutputFile" -ForegroundColor Yellow
    Write-Host "Script is stopped!" -ForegroundColor Yellow
	finalize
    exit 1
}


############################################################
# Loop foreach worksheet in output file (is a copy of file 1)
#############################################################
foreach($WorkSheet3 in $Workbook3.Worksheets)      
{
	$RowCount3 = $WorkSheet3.UsedRange.rows.count
    $ColCount3 = $WorkSheet3.UsedRange.columns.count
	$Name3 = $WorkSheet3.Name
	
	# Check if worksheet is available in worksheet 2. if not continue with next worksheet
    # -----------------------------------------------------------------------------------
	$WorksheetFound = $false
	foreach($Worksheet2 in $Workbook2.Worksheets)
	{
		$Name2 = $WorkSheet2.Name
		
		if($Name2 -eq $Name3)
		{
			$WorksheetFound = $true
			break
		}
	}
	
	if($WorksheetFound -eq $true)
	{
		Write-Host "Merging data for worksheet $Name3"
	}
	else
	{
		Write-Host "Worksheet $Name3 found in $InputFile1 is missing in $InputFile2" -ForegroundColor Yellow
		continue
	}
	
	# Get data from worksheet 2 and add it to worksheet 3 = output file
    # -----------------------------------------------------------------
	$Worksheet2 = $Workbook2.WorkSheets.item($Name3)
    $ColCount2  = $Worksheet2.UsedRange.columns.count  
	$RowCount2  = $Worksheet2.UsedRange.rows.count

    # for each column in worksheet 2
    # ------------------------------
    for($Col2 = 1; $Col2 -le $ColCount2; $Col2++)
    {
        $ColumnFound = $false
        $ColumnName2 = $Worksheet2.Cells.Item(1, $Col2).Text

        # Find column name from worksheet 2 in worksheet 3
        # ------------------------------------------------
        for($Col3 = 1; $Col3 -le $ColCount3; $Col3++)
        {
            if($ColumnName2 -eq $WorkSheet3.Cells.Item(1, $Col3).Text)
            {
                $ColumnFound = $true
                $Row3 = $RowCount3

                # Copy $Col2 to $Col3 in worksheet 3
                # ----------------------------------
                for($Row2 = 2; $Row2 -le $RowCount2; $Row2++)
                {
                    $Row3++
				
                    # Add column to output worksheet
                    # ------------------------------
				    $WorkSheet3.Cells.Item($Row3,$Col3) = $Worksheet2.Cells.Item($Row2,$Col2)
				    $WorkSheet3.Cells.Item($Row3,$Col3).NumberFormat = $Worksheet2.Cells.Item($Row2,$Col2).NumberFormat
                }
                break
            }
        }
   		# Column name in worksheet 2 not found in worksheet 3. Continue with next column
        # ------------------------------------------------------------------------------
		if($ColumnFound -eq $false) 
		{
			Write-Host "Column `"$ColumnName2`" found in worksheet $Name3 in $InputFile2 is missing in $InputFile1 --> skipped" -ForegroundColor Yellow
		}
    }
}

#################   
# Save ouput file
#################
try
{
	$Workbook3.Save()
}
catch
{
	Write-Host "Can not save xlsx to output file $OutputFile" -ForegroundColor Yellow
}
finally
{
	Finalize
}

exit 0

Open in new window

Avatar of patron

ASKER

above is solution for daily check but not the trend report for last 1 month,any solution to extract trend report for 30 days
ASKER CERTIFIED SOLUTION
Avatar of patron
patron
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial