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
Dead_EyesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Zephyr ICTCloud ArchitectCommented:
Maybe different Powershell versions?

You can find out the versions with this:

$PSVersionTable.PSVersion

Open in new window

0
Dead_EyesAuthor Commented:
Would be great if it was that but all 3 are running the exact same PS version :(
0
Zephyr ICTCloud ArchitectCommented:
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 :-)
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Dead_EyesAuthor Commented:
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
0
Zephyr ICTCloud ArchitectCommented:
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
0
Dead_EyesAuthor Commented:
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
0
Zephyr ICTCloud ArchitectCommented:
Maybe it's the hardware that's causing it? Different hardware, different ways of approaching it... That will be interesting if that's the case ... I'll try to dig a little deeper and test it on some systems here...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dead_EyesAuthor Commented:
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
0
Dead_EyesAuthor Commented:
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)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.