I’m stuck on something that I know is really simple but for the life of me can’t figure out.
I’m trying to import a .txt file with a list of hostnames, which once retrived, the script returns the amount of totalphysicalmemory installed.
so far I have this:
function get
{
$boxes = Get-Content C:\Temp\hostnamesforRAM.txt
foreach($box in $boxes)
{
Get-WmiObject Win32_ComputerSystem | select TotalPhysicalMemory
}
}
get
however, it just simply returns this:
4151570432
4151570432
4151570432
4151570432
4151570432
Any ideas?
Thanks
You need to pass the current hostname ($box) to the computerName parameter, without it you’re getting the value from your own computer.
Another way, more shorter, would be to pass the content of the file to the ComputerName parameter. The ComputerName parameter accepts a collection of names: