techthoughts2
12/28/2015 - 3:34 PM

Get WMI data from local and remote devices

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
#--------------------------------------------------------------------