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.

example:

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

 

Script:

Connect-VIServer -server %VCServerIPorDNSName% -protocol https -user %USERNAME% -password %PASSWORD%
$file=”c:DataStoreStatus.csv”
$GetInfoDataSt = Get-Datastore | Sort-Object Name

$DataStorages = @()

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

$stor.Name = $stores.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. Getting VMware Data Storages FreeSpace as CSV file on Vmware PowerCLI « cemoca FTW

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: