次の方法で共有


Powershell-How to query memory state via Get-WMIObject

here is a simple example how WMI queries can be call’d from powershell. this one is just an example and you can extend this by any system property like processors, available memory or even include disk space informations. all is about your needs and of course your creativity

$x = read-host -prompt "Please enter the machine name "
""
$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "root\CIMV2" -computername $x

foreach ($objItem in $colItems){
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)
$totalsockets=$colItems.NumberOfProcessors
write-host "Total Physical Memory:" $displayGB "GB"
write-host "Total CPU (Sockets) found:" $totalsockets
write-host "Model: " $objItem.Model
}

$colItems2 = get-wmiobject -class "Win32_Processor" -namespace "root\CIMV2" -computername $x

foreach ($objItem2 in $colItems2){
write-host "System Name:" $objItem2.SystemName
}
""

image

an example from a previous post, here I do calculate the memory pressure on a cluster node to identify oversubscribed hosts which can lead perf issues

image

Get-WMIObject
https://technet.microsoft.com/en-us/library/ee176860.aspx

WMIBrowser
https://wmie.codeplex.com/

the WMIBrowser is really useful when you do not know exactly what properties are available and how to call them

image

WMI is really powerful and nearly every Windows property can be called from there – Ok I see how you are thinking about all the creative ways now…Happy scripting Winking smile