Getting VMware Data Storages FreeSpace with percent as CSV file on VMware vSphere PowerCLI

If you need Data Storage free space of on your Vmware infrastructure (vSphere) as a Excel format ! Solution is here. I just need this information to follow my data growth in monthly or weekly. As you all know VMware does not provide this information like performans chart.


So just install VMware PowerCLI over here then write following script in a .ps1 file and save as getdatastorestatusascsv.ps1 via notepad or other text editor. Open Vmware PowerCLI on your desktop and  just run it wherever you saved. Like  “.getdatastorestatusascsv.ps1”


Do not forget determine csv file path, your Virtual Center IP address or DNS name, Username and Password for connect to Virtual Center in script.


Connect-VIServer -server -protocol https -user administrator -password Pwesd42#3




Connect-VIServer -server %VCServerIPorDNSName% -protocol https -user %USERNAME% -password %PASSWORD%
$GetInfoDataSt = Get-Datastore | Sort-Object Name

$DataStorages = @()

foreach ($stores in $GetInfoDataSt )
$stor = “” | Select-Object Name, CapacityGB, UsedGB, FreeGB, PercentUse

$stor.Name = $
$stor.CapacityGB = [math]::Round($stores.CapacityMB/1024,2)
$stor.UsedGB = [math]::Round(($stores.CapacityMB – $stores.FreeSpaceMB)/1024,2)
$stor.FreeGB = $stor.CapacityGB – $stor.UsedGB
$stor.PercentUse = [math]::Round(100*$stores.FreeSpaceMB/$stores.CapacityMB,2)
$stor.PercentUse = 100 – $stor.PercentUse
$DataStorages += $stor

$DataStorages | Export-csv -Path $file



  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: