Last active
December 28, 2015 15:34
-
-
Save techthoughts2/970d149f1ba1ff7ec40d to your computer and use it in GitHub Desktop.
Get WMI data from local and remote devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--------------------------------------------------------------------- | |
#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