question on finding CPUs for servers

I have a script that will return information from domain for all servers:

get-adcomputer -Filter{OperatingSystem -Like '*Windows Server*' -and UserAccountControl -notlike 4098} -Properties ipv4address, OperatingSystem, OperatingSystemServicePack| Select Name, ipv4address, OperatingSystem, OperatingSystemServicePack

I want to add to that script information about the number of physical and virtual CPUs. I have found out how to do it on a single computer:

Get-WmiObject –class Win32_processor | ft systemname,Name,DeviceID,NumberOfCores,NumberOfLogicalProcessors, Addresswidth

Its been awhile since I have worked with powershell so rusty as can be. I tried to add that in with another -and but does not work. Is there a way to approach this with my same methodology and get the information for the CPUs as well with this basic script I have?

This article may point you in the right direction

I do not think that get-adcomputer stores any information relating to operating system type or user account control

if you run Get-WmiObject –class Win32_processor -computername (get-adcomputer -filter *).name
You should be able to filter by the properties you are looking for afterwards.

Having said that the other day I found out that Powershell v5.1 has a command called get-computerinfo which does everything that the win32 objects does, so instead of writing out long commands for each class and filtering the info, you just run get-computerinfo and filter the information you want.

Thanks Ben that’s what I was after I have been doing networking for awhile now and was having problems remembering the basics of what is the correct word… hierarchy of () and brackets and while its basic 101 stuff I could not remember it and your point there is spot on to helping me down more specific path.

The other thing I was guessing at but you confirmed and that was about the adcomputer I was looking in active directory under attributes for a cupid but one did not exist so was guessing that also was not the right format.

A general approach question non related to specific code would be that is that normally how you want to use get-wmiobjects commands? start with it then the other stuff inside of it? I also liked those commands for wmiobjects as they can do a lot but never knew how to tie them in very well with my simple approach to doing power shell which is normally more along the lines of querying users or servers.

A lot of times people will use more advanced “if” statements and such which I took programming in college but am even more rusty on that even though I do have basic understanding of it when I see it and can reverse engineer my understanding much better than to create new things.

anyway thanks!

With SQL Server installations I’ve to use coreinfo tool to find out NUMA node information.
It’d be great if the get-computerinfo gave me that but it doesn’t.
Currently I use a function Get-NUMA, below, if there’s any better suggestions…?

function Get-NUMA {

param (
    [string]$coreinfoexe,
    [string]$outfile
    )

$ErrorActionPreference = 'SilentlyContinue'

    $arguments = "-n"
    $coreinfo = &$coreinfoexe $arguments 
    $coreinfo | select-string -pattern "NUMA Node" |  Out-File $outfile
    $numacount = (Get-Content $outfile)  | Where-Object { $_ -NotLike 'Logical Processor to NUMA Node Map' -and  $_ -Like '*-*NUMA Node*' }
    $numa = $numacount.Count

return $numa

}

Hi Ben,

I adapted the the script embedding mine into the Get-WmiObject

This did work but not exactly how I was looking for it to work. So might need a brief description and reminder on how this approaches the script.

My output was the following:

Script I used:

Get-WmiObject –class Win32_processor -computername (get-adcomputer -Filter{OperatingSystem -Like '*Windows Server*' -and UserAccountControl -notlike 4098} -Properties ipv4address, OperatingSystem, OperatingSystemServicePack| Select Name, ipv4address, OperatingSystem, OperatingSystemServicePack ).name

output I got:

Caption : Intel64 Family 6 Model 63 Stepping 2 DeviceID : CPU1 Manufacturer : GenuineIntel MaxClockSpeed : 2297 Name : Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz SocketDesignation : CPU socket #1

Caption : Intel64 Family 6 Model 44 Stepping 2
DeviceID : CPU0
Manufacturer : GenuineIntel
MaxClockSpeed : 2533
Name : Intel(R) Xeon(R) CPU E5649 @ 2.53GHz
SocketDesignation : Proc 1

You notice that none of the inner is outputted that its only the outer. Now what it did use from the inner parenthesis was going through each server.

What I am guessing by this output is that the outer said for this computer name (then get the computer name from whats inside the parenthesis) output the Win32_processor. Then it went through each server on the domain

However, I was hoping it would be smart enough to also pull the other information such as IP, and Name. This did not happen.

This may be why people are forced to use loop iterations or perhaps there is another way. I could use some help in grasping this concept better if possible.