Script to pull memory slots and installed memory on each slot

Answered Script to pull memory slots and installed memory on each slot

  • Wednesday, July 11, 2012 8:12 PM
     
     

    Hi Experts,

    Could you please share any scripts to find the memory slots and installed memory on each slot of servers.

    I have used wmic MEMORYCHIP get command, but it is not giving any slot information.


    Nidhin.CK System Analyst

All Replies

  • Wednesday, July 11, 2012 8:39 PM
     
      Has Code

    You can use the Win32_Physicalmemory class as such:

    wmic path win32_physicalmemory


    Jaap Brasser
    http://www.jaapbrasser.com

  • Wednesday, July 11, 2012 9:28 PM
     
     

    this command is not giving the entire available slots.. and it is not giving the slot number.

    i think this cmmand works in win7 machines.

    And do you know how to use WMI object browser. I dont know where can i find "win32_physicalmemory" calss ??

    Is it under root? root\WMI ? root\CIMV2 ?


    Nidhin.CK System Analyst

  • Wednesday, July 11, 2012 10:00 PM
    Moderator
     
     Proposed Answer Has Code

    i am not sure which class but check out the wmi code creator utility

    its very easy to use and generates the code for you

    http://www.microsoft.com/en-us/download/details.aspx?id=8572

    edit: try the Win32_PhysicalMemoryArray and the MemoryDevices property?

    script from wmicodecreator:

    strComputer = "." 
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_PhysicalMemoryArray",,48) 
    For Each objItem in colItems 
        Wscript.Echo "-----------------------------------"
        Wscript.Echo "Win32_PhysicalMemoryArray instance"
        Wscript.Echo "-----------------------------------"
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "CreationClassName: " & objItem.CreationClassName
        Wscript.Echo "Depth: " & objItem.Depth
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Height: " & objItem.Height
        Wscript.Echo "HotSwappable: " & objItem.HotSwappable
        Wscript.Echo "InstallDate: " & objItem.InstallDate
        Wscript.Echo "Location: " & objItem.Location
        Wscript.Echo "Manufacturer: " & objItem.Manufacturer
        Wscript.Echo "MaxCapacity: " & objItem.MaxCapacity
        Wscript.Echo "MemoryDevices: " & objItem.MemoryDevices
        Wscript.Echo "MemoryErrorCorrection: " & objItem.MemoryErrorCorrection
        Wscript.Echo "Model: " & objItem.Model
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "OtherIdentifyingInfo: " & objItem.OtherIdentifyingInfo
        Wscript.Echo "PartNumber: " & objItem.PartNumber
        Wscript.Echo "PoweredOn: " & objItem.PoweredOn
        Wscript.Echo "Removable: " & objItem.Removable
        Wscript.Echo "Replaceable: " & objItem.Replaceable
        Wscript.Echo "SerialNumber: " & objItem.SerialNumber
        Wscript.Echo "SKU: " & objItem.SKU
        Wscript.Echo "Status: " & objItem.Status
        Wscript.Echo "Tag: " & objItem.Tag
        Wscript.Echo "Use: " & objItem.Use
        Wscript.Echo "Version: " & objItem.Version
        Wscript.Echo "Weight: " & objItem.Weight
        Wscript.Echo "Width: " & objItem.Width
    Next


    Best Regards
    Jakob Gottlieb Svendsen
    Trainer/Consultant - Coretech A/S - Blog
    MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript Mastering System Center Orchestrator 2012 - 3 day workshop - worldwide training click here


  • Thursday, July 12, 2012 8:15 PM
     
     Answered

    Hi Guys,

    Issue reolved. Today i managed to find one script which pulls the total no of slots and installed memory on that.

    Referance:- http://www.powershellpro.com/dimm-witt/200/

    Script:-

    $strComputer = Read-Host "Enter Computer Name"
    $colSlots = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2" `
    -computerName $strComputer
    $colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2" `
    -computerName $strComputer

    Foreach ($objSlot In $colSlots){
         "Total Number of DIMM Slots: " + $objSlot.MemoryDevices
    }
    Foreach ($objRAM In $colRAM) {
         "Memory Installed: " + $objRAM.DeviceLocator
         "Memory Size: " + ($objRAM.Capacity / 1GB) + " GB"
    }


    Nidhin.CK System Analyst

    • Marked As Answer by Nidhin.CK Thursday, July 12, 2012 8:15 PM
    •