Max capacity of memory

Hello,

Need help to merge the below relevance to calculate the max capacity of memory. Or is there any other way to fetch the total ram installed on the machine.

I tried all the options available in Bigfix forum and also found in net, but did not work. I have build below relevance and gets the below output. I want to merge into one. E.g. It should give me the output as 8 GB.

Please help or advice

Q:((((string value of it as integer)/(1024x1024x1024)) as string) & " GB") of (selects "Capacity from Win32_PhysicalMemory" of wmi)
A: 4 GB
A: 4 GB
T: 13.339 ms
I: plural string

Hey there!

So it helps to think about this as in steps to understand why you’re getting the answer you’re getting.

When you run this query (selects "Capacity from Win32_PhysicalMemory" of wmi) you get two results back:

Q: (selects "Capacity from Win32_PhysicalMemory" of wmi)
A: Capacity=17179869184
A: Capacity=17179869184

When we use the of keyword that separates that section from the other section of your relevance we are saying do the thing on the left to every item on the right (both of them).

So in other words:
Do this: ((((string value of it as integer)/(1024x1024x1024)) as string) & " GB") to

A: Capacity=17179869184
A: Capacity=17179869184

Which is why you get:

A: 4 GB
A: 4 GB

So what we want to do instead is to use some piece of relevance that won’t output 1 object for each input object. In this case, we want to do a “sum” of the capacities before we format them.

So the first step would be to get them as numbers:

Q: (string value of it as integer) of (selects "Capacity from Win32_PhysicalMemory" of wmi)
A: 17179869184
A: 17179869184

The second step would be to sum them (so we have one object instead of two):

Q: (sum of (string value of it as integer) of (selects "Capacity from Win32_PhysicalMemory" of wmi))
A: 34359738368

The final step would be to apply your formatting:

Q: ((sum of (string value of it as integer) of (selects "Capacity from Win32_PhysicalMemory" of wmi)) / (1024 * 1024 * 1024)) as string & " GB" 
A: 32 GB
2 Likes

Thanks Strawgate!!! It works.

1 Like