$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}
}
0 Comments:
Post a Comment