Datastore Over provision script

Three days of boredom make me to write over provision script.So what script will do get you details about the DataCenter, Datastore Name, CapacityGB, AvailableGB, ProvisionedGB, PercentFree, VM count.I used function to calculate the percentage of free space.Follow the blog for future script updates

Script:

#OverProvision Report
#Version 1.0
#Author = Deepak K
#how to run the script
#connect to vCenter or Host Connect-VIserver -Server vcenter -user user -password password

function CalcPer{
param(
[parameter(Mandatory =$true)]
[int]$num1,
[parameter(Mandatory =$true)]
[int]$num2)
$num1/$num2*100
}

$overprovisionreport = @()

Get-DataCenter | Get-Datastore | %{
$data = “” | select DataCenter, Name, CapacityGB, AvailableGB, ProvisionedGB, PercentFree, VM
$data.DataCenter= $_.Datacenter
$data.Name = $_.Name
$data.CapacityGB = [Math]::Round($_.capacityMB/1024,2)
$data.AvailableGB = [Math]::Round($_.FreeSpaceMB/1024,2)
$data.ProvisionedGB = [Math]::Round(($_ExtensionData.Summary.Capacity – $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)
$data.PercentFree = CalcPer $data.AvailableGB $data.CapacityGB
$data.VM = (Get-VM).count
$overprovisionreport += $data
}
$data | Export-Csv “D:\test.csv” -NoTypeInformation -UseCulture

Please comment your feedback.

Advertisements

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