0

Below is the code snippet i tried but having an error because of it can anyone helpme in editing this one

  $colItems4 = Get-WMIObject -class Win32_PhysicalMemory | Measure-Object -Property capacity -Sum | 
       foreach ($objItem4 in $colItems4 )
       {
             write-host "Total Physical Ram : " $objItem4.Sum 
       }
4
  • 1
    I will also point out that you don't need that last pipe and that alone may be the problem. Commented Jul 16, 2013 at 19:45
  • What exactly are you trying to accomplish? Commented Jul 16, 2013 at 19:50
  • Wanted to find the Memory size of all the systems in the network with computer names provided to them the code above is just a small bit of the code Commented Jul 16, 2013 at 20:12
  • Kevin can you please help me in the other thread posted please stackoverflow.com/questions/17679674/… Commented Jul 16, 2013 at 20:13

3 Answers 3

3

You already had it. You just added too much.

Gwmi win32_PhysicalMemory | Measure-Object -Property Capacity -Sum

And if you wanted to show only the sum then:

Gwmi win32_physcialmemory | measure-object -property Capacity -sum | select sum
Sign up to request clarification or add additional context in comments.

Comments

1
$colItems4 = Get-WMIObject -class Win32_PhysicalMemory | Measure-Object -Property capacity -Sum
foreach ($objItem4 in $colItems4 )
{
     write-host "Total Physical Ram : " $objItem4.Sum 
}

Your code works fine. You just have an extra pipe at the end of your gwmi cmdlet.

Comments

0
   $colItems4 = Get-WMIObject -class Win32_PhysicalMemory  -computername $strComputer
      $colItems5=$colItems4 | Measure-Object -Property capacity -Sum 
      foreach ($objItem4 in $colItems5)
   {

      write-host "Memory :  " $colItems5.Sum
   }

Will solve the problem :D

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.