$scripthost = Read-Host "Enter the Hostname of the Computer you would like to check Memory Statistics for"
""
""
"===========CPU - Top 10 Utilization List==========="
gwmi -computername $scripthost Win32_PerfFormattedData_PerfProc_Process| sort PercentProcessorTime -desc | select Name,PercentProcessorTime | Select -First 10 | ft -auto
"===========Memory - Top 10 Utilization List==========="
gwmi -computername $scripthost Win32_Process | Sort WorkingSetSize -Descending | Select Name,CommandLine,@{n="Private Memory(mb)";Expression = {[math]::round(($_.WorkingSetSize / 1mb), 2)}} | Select -First 10 | Out-String
#gwmi -computername $scripthost Win32_Process | Sort WorkingSetSize -Descending | Select Name,CommandLine,@{n="Private Memory(mb)";e={$_.WorkingSetSize/1mb}} | Select -First 10 | Out-String
#$fields = "Name",@{label = "Memory (MB)"; Expression = {[math]::round(($_.ws / 1mb), 2)}; Align = "Right"};
"===========Server Memory Information==========="
$fieldPercentage = @{Name = "Memory Percentage in Use (%)"; Expression = { “{0:N2}” -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize)}};
$fieldfreeram = @{label = "Available Physical Memory (MB)"; Expression = {[math]::round(($_.FreePhysicalMemory / 1kb), 2)}};
$fieldtotalram = @{label = "Total Physical Memory (MB)"; Expression = {[math]::round(($_.TotalVisibleMemorySize / 1kb), 2)}};
$fieldfreeVram = @{label = "Available Virtual Memory (MB)"; Expression = {[math]::round(($_.FreeVirtualMemory / 1kb), 2)}};
$fieldtotalVram = @{label = "Total Virtual Memory (MB)"; Expression = {[math]::round(($_.TotalVirtualMemorySize /1kb), 2)}};
$memtotal = Get-WmiObject -Class win32_OperatingSystem -ComputerName $scripthost;
$memtotal | Format-List $fieldPercentage,$fieldfreeram,$fieldtotalram,$fieldfreeVram,$fieldtotalVram;