Help with Total volume capcity minus OS install.
i working on providing disk space capacity on our servers. thought had figured out calculations not correct.
i able find totalcapacity , totalfreespace have step remove 80 totalcapacity give final capacity per server.
so have list of servers in csv
import-csv $infile | foreach-object { $computer = $_.computername $adjustment = 80 later in script: $volumes = get-wmiobject -computer $computer -credential -class 'win32_volume' -filter 'drivetype=3' $volumes | foreach-object { $volume = $_ $volumename = $volume.name write-debug "`$volumename:,$volumename" #$size = 0 #$volumecapacity = $volume.capacity $totalcapacity += $volume.capacity #$freesize = 0 #$volumefreespace = $volume.freespace $totalfreespace += $volume.freespace } $adjustedcapacity = $totalcapacity - $adjustment inputobject: add-member -inputobject $properties -name 'total allocation (gb)' -value ($totalcapacity / 1gb).tostring("n2") -membertype noteproperty add-member -inputobject $properties -name 'subtracted amount (gb)' -value $adjustment.tostring("n0") -membertype noteproperty if ( $totalcapacity ) { $usedpercent = (($totalcapacity - $totalfreespace)/ $totalcapacity).tostring("p2") } else { $usedpercent = 0 } add-member -inputobject $properties -name 'used %' -value $usedpercent -membertype noteproperty add-member -inputobject $properties -name 'final adjusted allocation (gb)' -value ($adjustedcapacity / 1gb).tostring("n2") -membertype noteproperty
i'm hoping see total | subtracted amount | used | adjusted allocation, total , adjusted allocation same. $adjustment size not being reduced totalcapacity. don't see error , not sure why.
please advise.
thanks,
jr. admin
well want thank input. i'm still learning , trying figure out how ps works. wanted share findings in case noobie has entry level issues.
as turns out, figured out adjustment happening @ "kb" level.
as added gb adjustment amount, started work correctly.
$adjustment = 80gb
thanks again
jr. admin
Windows Server > Windows PowerShell
Comments
Post a Comment