I started working on a script to get CPU information and found I could use Get-WmiObject -class Win32_processor. I then started running into some other problems and lack of understanding.
For example I wanted to get the processors for all servers on the domain and so I molded together some code. (mind you was not worried about most efficient here but just why or why it does not work and how to approach).
following script:
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 below:
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 see that it gives me wmiobject information. In addition, it was giving me the information for every server. However it did not give me the ipv4 address and operating system and other information. So for some reason the portion:
-Properties ipv4address, OperatingSystem, OperatingSystemServicePack| Select Name, ipv4address, OperatingSystem, OperatingSystemServicePack ).name
did not work. It does not have to be this example but I am trying to understand in the most basic form how the scripts execute. From math I know its inner first and there may be something glaring here that is obvious that I am just missing.
I understand that the programming concept of Arrays might be a way to do this and store the information briefly then to be used with other information and I am way rusty on arrays but understand the concept but does that always have to be used here or is there more basic and caveman type methods that would have made my script work without something such as an array or variables? I will certainly study the other approach as well but that I did not catch something here may need to have it spelled out to me in basic talk lol…