Advertisement
cwprogram

Powershell + WMI Memory Info Summary

Jul 12th, 2011
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .SYNOPSIS
  3. This function sumarizes the properties of Get-WmiObject Win32_PhysicalMemory
  4. for those wanting to know what type of memory is needed for their PC.
  5.  
  6. .DESCRIPTION
  7. This function sumarizes the properties of Get-WmiObject Win32_PhysicalMemory
  8. for those wanting to know what type of memory is needed for their PC.
  9.  
  10. .OUTPUTS
  11. PSObject Collection. returns a collection custom objects with the following properties:
  12. Manufacturer - The manufacturer
  13. Capacity - Memory Capacity (bytes)
  14. Speed=RAM speed (nanoseconds)
  15. FormFactor=Form Factor (SODIMM,DIMM,etc.)
  16. MemoryType=Memory (DDR,SDRAM,etc.)
  17.  
  18. .INPUTS
  19. System.Management.ManagementObject#root\cimv2\Win32_PhysicalMemory piped input
  20.  
  21. .LINK
  22. Get-WmiObject
  23.  
  24. .LINK
  25. http://msdn.microsoft.com/en-us/library/aa394347%28v=vs.85%29.aspx
  26.  
  27. .EXAMPLE
  28. Get-WmiObject Win32_PhysicalMemory | Process-MemoryInfo
  29.  
  30. FormFactor   : SODIMM
  31. Manufacturer : Samsung
  32. MemoryType   : DDR-2
  33. Capacity     : 2147483648 bytes
  34. Speed        : 800 nanoseconds
  35.  
  36. FormFactor   : SODIMM
  37. Manufacturer : Samsung
  38. MemoryType   : DDR-2
  39. Capacity     : 2147483648 bytes
  40. Speed        : 800 nanoseconds
  41. #>
  42. function Process-MemoryInfo
  43. {
  44.     begin {
  45.         $memory_list = @()
  46.         $form_factor = @(
  47.             'Unknown',
  48.             'Other',
  49.             'SIP',
  50.             'DIP',
  51.             'ZIP',
  52.             'SOJ',
  53.             'Proprietary',
  54.             'SIMM',
  55.             'DIMM',
  56.             'TSOP',
  57.             'PGA',
  58.             'RIMM',
  59.             'SODIMM',
  60.             'SRIMM',
  61.             'SMD',
  62.             'SSMP',
  63.             'QFP',
  64.             'TQFP',
  65.             'SOIC',
  66.             'LCC',
  67.             'PLCC',
  68.             'BGA',
  69.             'FPBGA',
  70.             'LGA'
  71.         )
  72.         $memory_type = @(
  73.             'Unknown',
  74.             'Other',
  75.             'DRAM',
  76.             'Synchronous DRAM',
  77.             'Cache DRAM',
  78.             'EDO',
  79.             'EDRAM',
  80.             'VRAM',
  81.             'SRAM',
  82.             'RAM',
  83.             'ROM',
  84.             'Flash',
  85.             'EEPROM',
  86.             'FEPROM',
  87.             'EPROM',
  88.             'CDRAM',
  89.             '3DRAM',
  90.             'SDRAM',
  91.             'SGRAM',
  92.             'RDRAM',
  93.             'DDR',
  94.             'DDR-2'
  95.            
  96.         )
  97.     }
  98.     process {
  99.         $memory_list += New-Object PSObject -Property @{
  100.             Manufacturer=$_.Manufacturer;
  101.             Capacity=[string]::Format("{0} bytes", $_.Capacity);
  102.             Speed=[string]::Format("{0} nanoseconds", $_.Speed);
  103.             FormFactor=$form_factor[$_.FormFactor];
  104.             MemoryType=$memory_type[$_.MemoryType];
  105.         }
  106.     }
  107.     end {
  108.         return $memory_list
  109.     }
  110. }
  111.  
  112. function Get-MemoryInfo { Get-WmiObject Win32_PhysicalMemory | Process-MemoryInfo }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement