Hi,

Trying to get a script to map the correct physical ram...

I can use the below but its a 1mb short on some systems (even with the
extra 1 mb)

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
Output.WriteLine "Total Physical Memory: " &
objComputer.TotalPhysicalMemory /1024\1024+1 & "MB"
Next

I could also use

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from
Win32_PhysicalMemory")

For Each objItem in colItems
Wscript.Echo "Capacity: " & objItem.Capacity /1024\1024
Next

This does list the ram correctly however on a system with multiple
sticks of ram it lists the sticks separately.

Is there a command which will give me the total amount of ram (on every
system) without listing the sticks separetely?

Many Thanks

Re: *Correct* - Physical Ram by persillade

persillade
Tue May 31 12:58:57 CDT 2005

How about using the TotalVisibleMemorySize property from the
Win32_OperatingSystem class?

chris


Re: *Correct* - Physical Ram by inbox

inbox
Wed Jun 01 03:02:53 CDT 2005

Thanks for that...

When dividing the result by 1024 to get MB I'm getting a result which
is still inaccurate and has numbers after the decimal point i.e. for
512mb I'm getting 510.921875.

Is there a way to get the result rounded up?

Thanks


Re: *Correct* - Physical Ram by persillade

persillade
Wed Jun 01 08:01:48 CDT 2005

I think that you might be seeing the effects of having PAE (physical
addressing extensions) enabled. Check on that same class to see if
"PAEEnabled" = True.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_operatingsystem.asp

If it's enabled you will see a slight decrease in the amount of
expected RAM as seen here.

chris


Re: *Correct* - Physical Ram by inbox

inbox
Thu Jun 02 03:57:03 CDT 2005

Hi,

PAE isn't enabled - the problem only seems to be occuring when the
script is run against our laptops. When run against desktops/servers
the memory is reported correctly.... V.weird.

Thanks

Ben


Re: *Correct* - Physical Ram by persillade

persillade
Thu Jun 02 08:33:23 CDT 2005

That is bizarre. I'm afraid I don't have an explanation for that one!

chris


Re: *Correct* - Physical Ram by Joseph

Joseph
Fri Jun 03 12:46:25 CDT 2005

inbox@yeleek.co.uk wrote:
> Hi,
>
> Trying to get a script to map the correct physical ram...
>
> I can use the below but its a 1mb short on some systems (even with the
> extra 1 mb)
>
> Set colSettings = objWMIService.ExecQuery _
> ("Select * from Win32_ComputerSystem")
> For Each objComputer in colSettings
> Output.WriteLine "Total Physical Memory: " &
> objComputer.TotalPhysicalMemory /1024\1024+1 & "MB"
> Next
>
> I could also use
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2")
>
> Set colItems = objWMIService.ExecQuery("Select * from
> Win32_PhysicalMemory")
>
> For Each objItem in colItems
> Wscript.Echo "Capacity: " & objItem.Capacity /1024\1024
> Next
>
> This does list the ram correctly however on a system with multiple
> sticks of ram it lists the sticks separately.
>
> Is there a command which will give me the total amount of ram (on every
> system) without listing the sticks separetely?
>
> Many Thanks
>
Hi

I use the following

For Mb Size / 1048576
For Gb Size / 1073741824
For Tb Size / 1099511627776 (I wish...)

Joseph