For those working in a VMware environment with more than 1000 ESXi hosts, managing and making changes to each ESXi host without any automation can be very difficult. Fortunately, PowerCLI enables us to automate various vCenter tasks. In this discussion, I will explain how to retrieve storage details from vCenter and compile them into a single report.
This script is going to provide the below details:
vCenter Name
Runtime Name
UUID
Datastore Name
RDM VMs
Path Count
Dead/Inactive Path Count
Vendor
Capacity in GB
Multipath Policy
VMhost
IS Local storage
Operational State
Storage Model
This report can help you to do multipath checking in multiple clusters or vCenter. But it requires an input csv file(name- input_file.csv) in d: drive to take the input. Please find the input file format.
Steps performed in the script:
Get the input details from the CSV file
Login to vCenter
Get all the data store details from the respective ESXi
Get all the VMs details connected with RDMs with their UUID
Get all the SCSI Lun details
Get all the LUN path details
Keep all the outputs in the array and then compare
In all the outputs the UUID must be the same (means the UUID of data store must be present in the data store output, paths output and RDM LUN output if the RDM is connected)
Then compare the output get the path counts and dead path details and all properties of the data store and store every detail in the array.
Export the output and remove the variable so it will not append for the next ESXi input.
Please find the script below