Script to find Datastores with extent

Script to find Datastores with extents


This script will help VMware admins to find VMFS datastores with Extents (more than one Lun).

Prerequisite:-

1. Supported VMware PowerCLI Version 

How To:-

1. Save the code in a .ps1 file.
2.  Run the script in VMware Powercli.
3. It will prompt for the VC name against which it needs to be run, an Esxi name can also be           
    provided, if it needs to be run against only one Esxi followed by the credentials.
4. Script is tested and safe to run.
5. Result will be saved on the C drive, if you need to save it somewhere else then please modify the last line of the script with the desired path.
6. Out-put of the script will be displayed on screen.
7. Result will only be shown if there are Extents, in case of no Extents output would be empty.

Code:-

$vc=read-host provide the vCenter Name
write-host -foregroundcolor green "Connecting to VC" $vc
get-vc $vc
$x=get-esxcli -vmhost *
$devlist=$x.storage.vmfs.extent.list() | where-object{$_.extentnumber -gt "0"}
$devlist | select -Unique VolumeName, DeviceName, Extentnumber, Partition, VMFSUUID | ft -a
write-host -foregroundcolor yellow "Disconnecting from VC" $vc
disconnect-viserver $vc -confirm:$false


Comments