UNSOLVED

jcw9999

updated

11 years ago

J

jcw9999

3 Posts

0

41868

March 6th, 2015 10:00

Determine freespace %

Script:

$hostname = "asdasdf"
if (!(get-pssnapin | select-string "compellent")) {add-pssnapin compellent.storagecenter.pssnapin}
if (!($pass)) {$pass = read-host -assecurestring -prompt "password"}
$connection = get-scconnection -hostname $hostname -user Admin -password $pass

function freespace
{
[long]$totalblockscap = 0
[long]$totalblocksfree = 0
get-scdisk -connection $connection | ? {$_.controltype -eq "managed"} |
% {
$diskblockscap = [long]$_.totalblocks
[long]$totalblockscap = [long]$totalblockscap + [long]$diskblockscap

$diskblocksfree = [long]$_.unallocatedblocks
$diskblocksfree = $diskblocksfree - 86928
if ($diskblocksfree -le 0) {$diskblocksfree = 0}
$totalblocksfree = $diskblocksfree + $totalblocksfree
}

[decimal]$totaltbcap = ($totalblockscap*512/1024/1024/1024/1024) -as [decimal]
[decimal]$totaltbfree = ($totalblocksfree*512/1024/1024/1024/1024) -as [decimal]

[decimal]$freepercentage = $totalblocksfree/$totalblockscap*100

write-output "totalblockscap: $totalblockscap"
write-output "totalblocksfree: $totalblocksfree"
write-output "totaltbcap: $totaltbcap"
write-output "totaltbfree: $totaltbfree"
write-output "percentage free: $freepercentage"
}

freespace

================

Output:

PS >.\cmlmath.ps1
password: ***
totalblockscap: 103146873984
totalblocksfree: 117371904
totaltbcap: 48.0315061211586
totaltbfree: 0.0546555519104004
percentage free: 0.113791043263421

===============

I've got the totaltbcap to match what i see in sc, but totaltbfree doesnt match, nor does %free.

Not sure how to calcluate what sc calculates...

  • jcw9999

    3 Posts

    419

    0

    Posted March 6th, 2015 11:00

    btw, totaltbfree should be in the 3.5.... range.