i want RAM size of all server in domain.
this script help me in getting ram size localy but i want remotly for all server.
i tired foreach but dint sort it for me.
function Get-RAM {param([String[]]$Computers="$($env:COMPUTERNAME)")
foreach ($Computer in $Computers) {
$ht = @{}
CLS
$PhysicalRAM = (Get-WMIObject -class Win32_PhysicalMemory -ComputerName $Computer |
Measure-Object -Property capacity -Sum | % {[Math]::Round(($_.sum / 1GB),2)})
$ht.Add('Physical RAM GB',$PhysicalRAM)
$OSRAM = gwmi Win32_OperatingSystem -ComputerName $Computer |
foreach {$_.TotalVisibleMemorySize,$_.FreePhysicalMemory}
$ht.Add('Total Visable RAM GB',([Math]::Round(($OSRAM[0] /1MB),4)))
$ht.Add('Total Free RAM GB',([Math]::Round(($OSRAM[1] /1MB),4)))
$RAM = New-Object -TypeName PSObject -Property $ht
Write-Output $RAM | ft -AutoSize
}}
Get-RAM