Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active December 28, 2015 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/970d149f1ba1ff7ec40d to your computer and use it in GitHub Desktop.
Save techthoughts2/970d149f1ba1ff7ec40d to your computer and use it in GitHub Desktop.
Get WMI data from local and remote devices
#---------------------------------------------------------------------
#get WMI data loaded up
#--------------------------------------------------------------------
try{
$w32ProcInfo = Get-WmiObject -Namespace "root\cimv2" -Class win32_processor -Impersonation 3 -ComputerName $node
$w32OSInfo = Get-WmiObject -Namespace "root\cimv2" -Class Win32_OperatingSystem -Impersonation 3 -ComputerName $node
}
catch{
Write-Host "An error was encountered getting WMI info from $node" -ForegroundColor Red
Write-Error $_
Return
}
#--------------------------------------------------------------------
#load specific WMI data into variables
#--------------------------------------------------------------------
$name = $node
$numCores = $w32ProcInfo.numberOfCores
foreach($core in $numCores){
$totalNumCores += $core
}
$numLogicProcs = $w32ProcInfo.NumberOfLogicalProcessors
foreach($proc in $numLogicProcs){
$totalNumLogicProcs += $proc
}
$totalMemory = [math]::Round($w32OSInfo.TotalVisibleMemorySize /1MB, 0)
$freeMemory = [math]::Round($w32OSInfo.FreePhysicalMemory /1MB, 0)
$totalClusterRAM += $totalMemory
#--------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment