Skip to main content

vCenter Server | How to get percentage free space of a datastore?


$vcenter = read-host "Enter vCenter server FQDN "
Connect-VIServer $vcenter
echo "Welcome to Datastore free space calculator tool"
echo ""
echo " Press 1 to search details for single datastore"
echo " Press 2 to search details for all the datastores"

$data = Read-Host "Enter your choice"
If($data -eq 1 )
{
$a= Read-Host " Please enter the name of DS"
$DS= Get-Datastore
Get-Datastore | where{$_.Name -eq $a} | Select @{N="DataStoreName";E={$_.Name}},@{N="Percentage Free Space(%)";E={[math]::Round(($_.FreeSpaceGB)/($_.CapacityGB)*100,2)}} | Where {$_."Percentage(<20%)" -le 20}
}

elseif ($data -eq 2 )
 { 
Get-Datastore | Select @{N="DataStoreName";E={$_.Name}},@{N="Percentage Free Space(%)";E={[math]::Round(($_.FreeSpaceGB)/($_.CapacityGB)*100,2)}} | Where {$_."Percentage(<20%)" -le 20}

}


Comments

Popular posts from this blog

Network Migration | VLAN to VXLAN

NSX-T | Getting Started with PowerCLI

NSX-T | Security

Automate Power on Operations using PS