Wednesday 4 July 2018

Hyper-V host running core - check RAM from remote server with Powershell

 

 

Here's a little script I created that was useful to check the amount of physical RAM installed on a Hyper-V server running core.  It reports the amount of physical RAM in the host as well as the amount of RAM which is actually visible and addressable to the server.  It also reports the RAM which is currently assigned the Hyper-V host OS..

 

 

Add-Type -AssemblyName PresentationFramework

$Server = "ADVYOHV01"

$PRAM = (Get-WMIObject -class Win32_PhysicalMemory -ComputerName $Server |`

Measure-Object -Property capacity -Sum | % {[Math]::Round(($_.sum / 1GB),2)})

$IRAM = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Server

$IRAM = [Math]::Round(($IRAM.TotalPhysicalMemory/ 1GB))

$CheckHost = Get-Ciminstance Win32_OperatingSystem

$PCTFREE = [math]::Round(($CheckHost.FreePhysicalMemory/$CheckHost.TotalVisibleMemorySize)*100,0)

$GBFREE = [math]::Round($CheckHost.FreePhysicalMemory/1mb,2)

$TOTALGB = [int]($CheckHost.TotalVisibleMemorySize/1mb)

[System.Windows.MessageBox]::Show("Hardware`:

`n$PRAM`GB Physical Memory `($IRAM`GB addressable`)

`n

`nCurrent OS Usage`:

`n$GBFREE`GB free out of $TOTALGB`GB total `($PCTFREE`% used`)","Memory details for server `"$Server`"")

 

 

No comments:

Post a Comment