Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retreive a Servers RAM info

Status
Not open for further replies.

lauraSatellite

Technical User
Jul 22, 2004
35
IE
I am relatively new to vbscript. I am trying to retrieve the RAM in mb for a server. I enter the server name in the code, and use the following code to retrieve the ram:

GetServerInfo Array("servername"), "C:\SRVINFO.CSV", ","

Sub GetServerInfo(aServers, sFileName, sDel)
set oFSO = CreateObject("Scripting.FileSystemObject")
set oText = oFSO.CreateTextFile("Path\Results.txt")
columns = "sServer" & "," & "RAM"
oText.WriteLine columns

for each sServer in aServers
Set objWMIService = GetObject("WINMGTS" & sServer & "ROOT")

Set ColMemory = objWMIService.ExecQuery _
("select * from Win32_CacheMemory")
for each mem in ColMemory
Memory = "," & Trim(mem.Caption)
Next
INV = sServer & Memory
oText.Writeline INV
Next
End Sub


This code returns "Cache Memory" as the RAM field. I have tried getting a number of other variables within Win32_CacheMemory, but i have been unable to find the correct variable. If you know what i should be calling other than Win32_CacheMemory.Caption, i would really appreciate it if you could let me know. Thanks in advance.
 
Hello lauraSatellite,

[1] Correct vital binding string:
"WINMG[red]M[/red]T[red]:\\[/red]" & sServer & "[red]\[/red]ROOT[red]\cimv2[/red]"
[2] Retrieve rather from win32_physicalmemeory class. The capacity attribute returns you the ram in bytes. Sum over the available slots and integral divide the total by 1024*1024 to give you the capacity in Megabytes.

regards - tsuji
 
thanks so much for replying :) im in such a rush to get this working! i have the vital binding correct in my file, but i will try physicalmemory instead, thanks!
 
Further note:

The correction [1] suggested is not completed yet. Sorry! It is this.
[tt] "WINMG[red]M[/red]T[red]S:\\[/red]" & sServer & "[red]\[/red]ROOT[red]\cimv2[/red]"

- tsuji
 
i have been working on this problem for a while, but am stuck on another aspect. I also need to get the servers install date. I have used a similar method to above, but calling the following:

Win32_Product.InstallDate
Win32_BaseService.InstallDate
Win32_BIOS.InstallDate


All of the abover return null.
If you are aware of what i should be calling instead of the above, i would really appreciate it if you could let me know. Thanks a million
 
lauraSatellite,

Download free "scriptomatic" from ms and run it to get basic syntax right.

Furthermore, properties are supported universally. Some just are not supported; or planned but undeveloped; or conditioned by the hard/software suppliers' compliance.

- tsuji
 
Correction:

I meant:-
Furthermore, properties are [red]not[/red] supported universally...

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top