problem with my script

i’m newbie i’m learning powershell.i created simple script but i cannot received freephysicalmemory from my script. why

function Get-HostProperties{

param ($computerName = (Read-Host "Enter Computer Name")

Get-WmiObject -Class win32_logicaldisk -ComputerName $computerName -Credential dri\administrator | ft DeviceID, @{Name="Free Disk Space (GB)";e={$_.FreeSpace /1GB}}, @{Name="Total Disk Size (GB)";e={$_.Size /1GB}} -AutoSize
Get-WmiObject -Class win32_computersystem -ComputerName $computerName -Credential dri\administrator|ft @{Name="Physical Processors";e={$_.NumberofProcessors}} ,@{Name="Logical Processors";e={$_.NumberOfLogicalProcessors}}, @{Name="TotalPhysicalMemory (GB)";e={[math]::truncate($_.TotalPhysicalMemory /1GB)}}, @{Name="FreePhysicalMemory (GB)"; e={[math]::Round($_.FreePhysicalMemory/1024)}}, Model -AutoSize

“FreePhysicalMemory” is not a property of Win32_ComputerSystem

Also, as you’re just getting started, using Read-Host to prompt for a parameter value is generally a poor practice.

function Get-HostProperties {

Will cause a prompt for the value if it isn’t provided. This is the preferred way to accomplish that. Learn PowerShell Toolmaking in a Month of Lunches covers that and other techniques. Additionally, formatting your output within the function is a common “gotcha” and leads the output being less useful. In your function, for example, you cannot pipe the output of Get-HostProperties to anything like Export- or ConvertTo- or anything. See our free ebook, The Big Book of PowerShell Gotchas or Learn Windows PowerShell in a Month of Lunches. Generally, functions should not format output. You can accomplish the same thing, in a more flexible fashion, by using Select-Object instead of Format-Table.

Good luck!