I am trying to find the total number of CPUs on a computer via get-wmiobject
. The query: select * from win32_processor
returns more than 1 row if there is more than 1 processor on the computer. WQL doesn't have the count
keyword like in TSQL. So I am just wondering whether there is another way to find the total number of rows returned?
You can just force it into an array and use the Count
property:
@(gwmi win32_processor).count
For the specific case, if you are just looking for number of processors, you can do:
$env:NUMBER_OF_PROCESSORS