Script For Datastore Utilization

Script For Datastore Utilization

This script is very useful to generate the Datastore Utilization of  VMware Infra

Save the below script as .PS1 extension  and Run fron vSphere Power CLI ,  Out Put will be saved on  the Location where we mention  , here it is c:\datstoreusage.csv

Connect-VIServer (MyvCenter) -User (My Username)-Password (My Password)

Get-Datastore |

Select Name,

@{N=’Type’;E={“$($_.Type)$($_.ExtensionData.Info.Vmfs.MajorVersion)”}},

@{N=’CapacityGB’;E={[math]::Round($_.CapacityGB)}},

@{N=’FreeSpaceGB’;E={[math]::Round($_.FreeSpaceGB)}},

@{N=’UsedSpaceGB’;E={[math]::Round($_.CapacityGB – $_.FreeSpaceGB,1)}},

@{N=’% of LUN Utilization’;E={[math]::Round(($_.CapacityGB – $_.FreeSpaceGB)/$_.CapacityGB * 100,1)}} |

Export-Csv   c:\datstoreusage.csv  -NoTypeInformation -UseCulture