Root Loop
Root Loop

Reputation: 3162

Check memory type (ECC or not) by using PowerShell

I am trying to check memory types on all PCs across company. My testing code is below based on info from here:

Get-WmiObject Win32_PhysicalMemory |
    Select-Object -Property PSComputerName, DeviceLocator, Manufacturer, PartNumber, @{label = "Size/GB" ; Expression = {$_.capacity / 1GB}}, Speed, datawidth, totalwidth, @{label = "ECC" ; Expression = {
        if ( $_.totalwidth > $_.datawidth ) {
            "$($_.DeviceLocator) is ECC memory type"
        }
        else {
            "$($_.DeviceLocator) is non-ECC Memory Type"
        }
    }
} | Out-GridView 

The results showing me that memory type is non-ecc:

enter image description here

But if I use 3rd party tool like "HWiNFO64 v4.30" the result is ECC memory. See pic below. How can I get the same memory info like pic below by using PowerShell? Speciously "Memory type" "Speed" and "ECC"

enter image description here

Upvotes: 2

Views: 2728

Answers (1)

Matt
Matt

Reputation: 46710

Vikas could have some good points about the accuracy of the information which should be considered. The linked post eludes to other issues as well.

The issue you are running into with this code is your use of PowerShell Comparison Operators.

They are in the format of -gt and -lt for example which are greater than and less than respectively. Assuming your logic you should just have to update

if ( $_.totalwidth > $_.datawidth )

to

if ( $_.totalwidth -gt $_.datawidth )

Upvotes: 2

Related Questions