Powershell to Get Memory

Hello,

I am running SCOM 2012 R2.  I would like to know if there is a Powershell command to retrieve the amount of physical memory in my clients.  I need to know which computers are under 8GB so I can upgrade them.

June 18th, 2015 9:48am

Get-WMIObject -class win32_physicalmemory -computer $computer | where { $_.capacity -lt "8000000000"}

Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 10:32am

Hello,

I tried your command and I get:

Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty

I am looking for a way to list all of the computers in one column and their physical memory in another column.  I currently do that with their MAC addresses so I would like the same results if it's possible.

June 18th, 2015 10:36am

Import-Module activedirectory

$Computers = Get-ADComputer -filter *

Foreach($Computer in $Computers){

    Get-WMIObject -class win32_physicalmemory -computer $Computer.samaccountname | where { $_.capacity -lt "8000000000"} | Format-Table devicelocator, capacity -a

    }
Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 10:57am

Hello,

Can you please give me instructions on how to apply this?  Im not too familiar with Powershell.

June 18th, 2015 11:19am

  1. On a server with ADDS (Active Directory Domain Services) installed or at least the Active Directory PS module
  2. Create the folder c:\scripts
  3. Create a txt file and copy the script into it
  4. Save the txt file and rename it whatever.ps1 (the .ps1 extension is the important part)
  5. Open a powershell window
  6. Run c:\scripts\whatever.ps1
  7. Read outputs
  8. Hack the Gibson
  9. Save the princess
  10. Live long and prosper 
Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 12:35pm

Hello,

Unfortunately I do not have access to the AD servers.  I have to be able to do it solely through SCOM.  Btw..I love #9 and #10.  You should add #11.  May The Force be with you.

June 18th, 2015 12:53pm

Import-Module operationsmanager

$SCOMMS = "YourManagementServerGoesHere"

$class = Get-SCOMClass -Name Microsoft.Windows.Computer -ComputerName $SCOMMS
$Computers = Get-SCOMClassInstance -ComputerName $SCOMMS | where {$_.MonitoringClassIds -eq $class.id} 
 

Foreach($Computer in $Computers){

    Get-WMIObject -class win32_physicalmemory -computer $Computer.displayname | where { $_.capacity -lt "8000000000"} | Format-Table pscomputername, capacity -a

    }
Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 2:01pm

Hello,

When I run this I get the following:

Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\Memory.PS1:11 char:18
+     Get-WMIObject <<<<  -class win32_physicalmemory -computer $Computer.displayname | where { $_.capacity -lt "800000
0000"} | Format-Table pscomputername, capacity -a
    + CategoryInfo          : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

June 19th, 2015 9:37am

Hello,

As I ran it again, I realized what was going on.  This process runs and queries each client instead of querying the SCOM DB.  That's why I got the RPC error, because it scanned a conputer that was off.  Am I correct?  If that's the case, then this wont work for me.  I was looking for something similar to the way I retrieve MAC and IP addresses, which is from the DB and not a query of each computer.  Is it possible to do it with memory as well?

Free Windows Admin Tool Kit Click here and download it now
June 19th, 2015 9:55am

There are two ways to display SCOM agent physical memory

1) Using operations console --> Monitoring --> Discovered Inventory and change it type into Windows Server Operating System

2) Using the following powershell

get-scomclass -displayname 'Windows Server Operating System' | get-scomclassinstance |ft ``[Microsoft.Windows.OperatingSystem`].physicalMemory, ``[Microsoft.Windows.Computer`].PrincipalName

Roger

June 20th, 2015 4:52am

There are two ways to display SCOM agent physical memory

1) Using operations console --> Monitoring --> Discovered Inventory and change it type into Windows Server Operating System

2) Using the following powershell

get-scomclass -displayname 'Windows Server Operating System' | get-scomclassinstance |ft ``[Microsoft.Windows.OperatingSystem`].physicalMemory, ``[Microsoft.Windows.Computer`].PrincipalName

Roger

  • Marked as answer by jsetaro 14 hours 57 minutes ago
Free Windows Admin Tool Kit Click here and download it now
June 20th, 2015 8:50am

There are two ways to display SCOM agent physical memory

1) Using operations console --> Monitoring --> Discovered Inventory and change it type into Windows Server Operating System

2) Using the following powershell

get-scomclass -displayname 'Windows Server Operating System' | get-scomclassinstance |ft ``[Microsoft.Windows.OperatingSystem`].physicalMemory, ``[Microsoft.Windows.Computer`].PrincipalName

Roger

  • Marked as answer by jsetaro Monday, June 22, 2015 4:13 PM
June 20th, 2015 8:50am

Hello,

They both worked like a charm.  Thank you so much.

Free Windows Admin Tool Kit Click here and download it now
June 22nd, 2015 12:15pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics