Skip to content

Instantly share code, notes, and snippets.

@bohack
Created January 30, 2018 14:44
Show Gist options
  • Save bohack/5c9860ffac24599c3dc98da4d2760549 to your computer and use it in GitHub Desktop.
Save bohack/5c9860ffac24599c3dc98da4d2760549 to your computer and use it in GitHub Desktop.
Get Total RAM from a PC via VBscript WMI
On Error Resume Next
Prefix ="fstu516"
For Count = 1 to 36
Total = 0
If Count < 10 then Fill="00"
If Count < 100 and Count > 9 then Fill="0"
strComputer = Prefix & Fill & Count
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
For Each objItem in colItems
Total = abs(Total) + objItem.Capacity
Next
Wscript.Echo strComputer & " " & Total/1024
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment