La Tecnología hecha fácil en Español y ahora en English
VMware, as a leading virtualization platform, has created the need for specialized tools that simplify the management and monitoring of virtualized environments. Among these tools, RVTools, vCheck, vDiagram, and AsBuiltReport stand out, each offering unique features to streamline the administration of virtual machines.
RVTools es una aplicación de código abierto que proporciona información detallada sobre tus entornos de VMware vSphe RVTools is an open-source application that provides detailed information about your VMware vSphere environments.
Download: https://www.robware.net/rvtools/
RVTools has become a fundamental tool for VMware administrators, providing comprehensive visibility and simplifying issue resolution.
vCheck is a scripting framework that enables the generation of detailed and customizable reports on VMware environments.
vDiagram is a visualization tool that creates visual diagrams of VMware vCenter environments.
Download: https://github.com/Tony-SouthFLVMUG/vDiagram2.0
The ability to visualize the topology of the environment facilitates understanding and informed decision-making
AsBuiltReport is a tool that automatically generates detailed reports on the configuration of VMware environments.
Download: https://github.com/orgs/AsBuiltReport/repositories?q=VMware&type=all&language=&sort=
AsBuiltReport simplifies documentation and ensures that your environment follows best practices recommended by the community.
After discussing the above tools, I would like to share an experience I had a few days ago. I found myself in need of a report for a large VMware platform, but despite my efforts with the aforementioned tools, I couldn’t achieve the desired results. These tools, at some point in the report generation, encountered errors and produced incomplete reports. So, I had no choice but to create my own script to generate the desired report. I turned to VMware’s PowerCLI and wrote my own PowerShell script. It wasn’t easy, nor was it difficult—I just needed a bit of patience and to learn the commands during the process.
So, before concluding this article, let me share the process I had to go through to create the script and generate my own report:
1.- Validate the version of PowerShell using the command $psversiontable. To do this, open PowerShell with administrator privileges
2.- Install the PowerCLI module for PowerShell by running the following command: Install-Module -Name VMware.PowerCLI. Choose the option that fits your needs; in my case, I selected option A to install everything.
3.- After installation, verify that you can list the different PowerCLI commands.
# Get-Module -ListAvailable -Name VM*
4.- Now that we have the PowerCLI module installed, we proceed to connect to the VMware platform with the following command:
# Connect-VIServer -Server ip-vCenter -User Nombre-user@dominio -Password clave-usuario
5.- From now on, you will be connected to the VMware platform, and you just need to execute the commands you need to obtain the data and reports you desire. Keep in mind that when you finish, you should execute the following command to disconnect from the VMware platform or, in other words, log out.
# Disconnect-VIServer -Server * -Force -Confirm:$false
I’ll leave you here with 2 scripts that I’ve used
This script generates a report of the VMs that are powered off and saves the information in a file *.csv
Connect-VIServer -Server x.x.x.x
$Report = @()
$VMs = Get-VM | Where-Object {$_.PowerState -eq “PoweredOff”}
$Datastores = Get-Datastore | Select Name, Id
foreach ($VM in $VMs) {
$row = ” | Select VMName, Powerstate, OS, Host, Cluster, Datastore, NumCPU, MemMb, DiskGb, PowerOFF
$row.VMName = $VM.Name
$row.Powerstate = $VM.Powerstate
$row.OS = $VM.Guest.OSFullName
$row.Host = $VM.VMHost.Name
$row.Cluster = $VM.VMHost.Parent.Name
$row.Datastore = ($Datastores | Where-Object {$_.ID -match ($VM.Datastore | Select-Object -First 1).Id} | Select-Object Name).Name
$row.NumCPU = $VM.NumCPU
$row.MemMb = $VM.MemoryMB
$row.DiskGb = ((($VM.HardDisks | Measure-Object -Property CapacityKB -Sum).Sum * 1KB / 1GB) -as [int])
$PowerOffEvent = Get-VIEvent -Entity $VM -MaxSamples 1 | Where-Object {$_.GetType().Name -eq “VmPoweredOffEvent”}
if ($PowerOffEvent) {
$row.PowerOFF = $PowerOffEvent.CreatedTime
} else {
$row.PowerOFF = “N/A”
}
$Report += $row
}
$Report | Sort VMName | Export-Csv -Path “C:\Reports\VM-PowerOFF_TEST-3.csv” -NoTypeInformation -UseCulture
Disconnect-VIServer -Server * -Force -Confirm:$false
This script generates a *.csv file with the main information of the VMs in the platform. If you want more information for each VM, you just need to add the desired fields.
Connect-VIServer -Server ‘x.x.x.x’ -User ‘user@dominio.local’ -Password ‘password’
$vmReport = Get-VM | Select-Object Name, PowerState, NumCpu, MemoryGB,
@{N=‘ProvisionedSpaceGB’; E={[math]::Round($_.ProvisionedSpaceGB, 1)}},
@{N=‘UsedSpaceGB’; E={[math]::Round($_.UsedSpaceGB, 1)}},
@{N=‘vDisk#’; E={(Get-HardDisk -VM $_).Count}},
@{N=‘Controller#’; E={(Get-ScsiController -VM $_).Count}},
@{N=‘NetworkAdapter#’; E={(Get-NetworkAdapter -VM $_).Count}},
@{N=‘IPAddresses’; E={ (Get-NetworkAdapter -VM $_ | Where-Object {$_.IPAddresses -ne $null} | ForEach-Object { $_.IPAddresses }) -join ‘, ‘ }}
$vmReport | Export-Csv -Path “C:\Reports\reporte.csv” -NoTypeInformation
Disconnect-VIServer -Confirm:$false
These tools provide a clearer and more detailed insight into VMware environments, enhancing operational efficiency and enabling administrators to make more informed decisions. By integrating RVTools, vCheck, vDiagram, and AsBuiltReport into your administration processes, you can optimize virtual machine management and ensure your virtualized environment is in its best shape. However, when none of these tools seems to work, we can always turn to PowerCLI within PowerShell.