Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Powershell returns Negative Infinity

$
0
0

Hi Experts,

I am using a formula to calculate average RAM percentage utilization. I have this script running in my machine for several months. This is the first weird time that i got a negative infinity as a results. I have no idea how this would have occurred and how to handle this. ?

I dont know what would have been the values of UsedRAM and TotalRAM that time. ! 

Can you please help me understand?

$TotalRAM = (get-WMIObject win32_operatingsystem -computername $servername | Measure-Object TotalVisibleMemorySize -sum).sum / 1024  

$FreeRAM = ((get-WMIObject -computername $servername -class win32_operatingsystem).freephysicalmemory) / 1024   

$UsedRAM = (($TotalRAM) - ($FreeRAM))  

$RAMPercentUsed = ([math]::truncate(($UsedRAM) / ($TotalRAM) * 100))   

$RAMPercentUsed  Result is '-Infinity'


Viewing all articles
Browse latest Browse all 6937

Trending Articles