Powershell: Foreach Input -


I'm stuck in something that I know is really simple, but do not understand this for my life is coming.

I am trying to import a .txt file with a list of hostnames, which once recovered, the script has installed a total fee memory memory.

I still have this: get the function {$ box = get-content C: \ temp \ hostnamesforRAM.txt foreach ($ box $ in box) { Get-WmiObject Win32_ComputerSystem |

Select

However, it only gives:

  4151570432 4151570432 4151570432 4151570432 4151570432   

Any ideas?

Thank you

You get the current hostname ($ box) without the computername parameter, its Without you getting the price from your computer. Get the

  function {$ boxes = get-content C: \ temp \ hostnamesforRAM.txt foreach ($ box $ in box) {Get-WmiObject Win32_ComputerSystem -ComputerName $ box | Select total physical memory}}   

Another way, more small, the contents of the file must be passed in the ComputerName parameter. The computer name accepts a collection of parameter names:

  Get-WmiObject Win32_ComputerSystem-ComputerName (Get-content C: \ Temp \ hostnamesforRAM.txt) | Selection object name, total physical memory    

Comments