Link to home
Start Free TrialLog in
Avatar of Dead_Eyes
Dead_EyesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell Get-CimInstance -ClassName Win32_PhysicalMemoryArray

This is probably going to be an easy one for someone out there. I am learning PowerShell and writing a script to detect memory configurations on machines and failing at the first hurdle of how many memory slots does a machine have and how many are populated. At first the command "Get-CimInstance -ClassName Win32_PhysicalMemoryArray" was a blessing as the property BankLabel or devicelocator looked like a win however I have 2 machines with win8.1 and one machine with server 2012R2 on and on 1 8.1 machine the propertys devicelocator and banklabel don't exist but memorydevices does and on the other 2 (8.1&2012R2) memorydeices does not exist but devicelocator and banklabel do. In short WTF how can I have two different sets of properties from the same command on the same version of PS? Thanks in advance
Avatar of Zephyr ICT
Zephyr ICT
Flag of Belgium image

Maybe different Powershell versions?

You can find out the versions with this:

$PSVersionTable.PSVersion

Open in new window

Avatar of Dead_Eyes

ASKER

Would be great if it was that but all 3 are running the exact same PS version :(
Did you also look at available scripts like this one or this one ...

If these work (with maybe a slight adjustment here or there) you'll be set ... No need to reinvent the warm water :-)
Yeah I have been getting idea's from them and all get information from one of the properties so will fail in the same way. I am writing myself as its a lot better for learning and really even if I don't end up with a working script and just end up with the knowledge of why and how properties can change its still a win
Well ... Maybe you need to work in an if statement that checks the OS before running the actual command, that way you could use either this or that command ... That is, if it is indeed different on all W2K12R2 servers and W8.1 respectively
Its not though that's my point on 1 x 8.1 and 1 x 2012r2 machine its one set of properties and on another 8.1 machine its another set of properties even though all machines are running PS v4
ASKER CERTIFIED SOLUTION
Avatar of Zephyr ICT
Zephyr ICT
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I can fully appreciate some manufacturers not filling in bits of information but to change the name of the property just seems so out of place. I was thinking maybe it's based on type of machine (laptop v desktop) but even if why change a property name as it's just going to cause chaos like this
Ok I feel like an idiot now I got so caught up in exploring the Get-CimInstance instead of my usual Get-WMIObject I only just realised I was calling a cim class on one machine and a win32 class on the other........ Feeling like such a dumbass atm (points awarded for me wasting everyone's time)