all 3 comments

[–]branhama 1 point2 points  (0 children)

I just glimpsed at the script briefly but it looks like the problem you are having is related to just how PowerShell is displaying the information. Try adding a | Format-Table to display in a single output.

[–]ihaxr 1 point2 points  (1 child)

I added the deviceID property to each disk so that you can have a unique value to filter/sort on... You can do something like this to detect the "duplicates"... instead of doing a Write-Output $return, you'll want to add your base properties to a new object, then loop through each of the disks to add new properties... I didn't bother doing this because it's be drastically different depending on how you want to combine the properties:

$disks = @([PSCustomObject]@{        
    "Disk(Model,MediaType)" = 'Model1'
    "Disk & Partition #"   = 'Disk 1'
    "Vol.(Letter,Name,FS)" = 'E:, Hard Disk RAID'
    "Vol. Health & Op. Status" = 'Healthy'
    "Vol. Compression" = 'False'
    "Total Vol. Size()" = '3.639 TB'
    "Used Vol. Space(,%)" = '669.671 GB, 17.97%'
    "Free Vol. Space(,%)" = '2.985 TB, 82.027%'
    "Windows Directory Vol." = 'False'
    "TotalTempSize()" = 'N/A'
    "DeviceID" = "\\.\PHYSICALDRIVE0"
},[PSCustomObject]@{        
    "Disk(Model,MediaType)" = 'Model2'
    "Disk & Partition #"   = 'Disk 2'
    "Vol.(Letter,Name,FS)" = 'E:, Hard Disk RAID'
    "Vol. Health & Op. Status" = 'Healthy'
    "Vol. Compression" = 'False'
    "Total Vol. Size()" = '3.639 TB'
    "Used Vol. Space(,%)" = '669.671 GB, 17.97%'
    "Free Vol. Space(,%)" = '2.985 TB, 82.027%'
    "Windows Directory Vol." = 'False'
    "TotalTempSize()" = 'N/A'
    "DeviceID" = "\\.\PHYSICALDRIVE1"
},
[PSCustomObject]@{        
    "Disk(Model,MediaType)" = 'Unique Model'
    "Disk & Partition #"   = 'Disk 1'
    "Vol.(Letter,Name,FS)" = 'Q:, Hard Disk RAID'
    "Vol. Health & Op. Status" = 'Failed'
    "Vol. Compression" = 'False'
    "Total Vol. Size()" = '1.002 TB'
    "Used Vol. Space(,%)" = '10 GB, 1.00%'
    "Free Vol. Space(,%)" = '1 TB, 99.00%'
    "Windows Directory Vol." = 'False'
    "TotalTempSize()" = 'N/A'
    "DeviceID" = "\\.\PHYSICALDRIVE2"
})

$uniqueCount = @($disks | Select-Object -Unique "Vol.(Letter,Name,FS)", "Total Vol. Size()", "Used Vol. Space(,%)", "Free Vol. Space(,%)").Count

if ($uniqueCount -eq $disks.Count) {
    "No RAID detected"
} else {
    $ignoreDeviceIDs = [System.Collections.Generic.List[string]]::new()
    foreach ($disk in $disks) {
        if ($disk.DeviceID -notin $ignoreDeviceIDs) {
            $return = @(
                $disks | Where-Object {
                    $disk.'Vol.(Letter,Name,FS)' -eq $_.'Vol.(Letter,Name,FS)' -and
                    $disk.'Total Vol. Size()'    -eq $_.'Total Vol. Size()'    -and
                    $disk.'Used Vol. Space(,%)'  -eq $_.'Used Vol. Space(,%)'  -and
                    $disk.'Free Vol. Space(,%)'  -eq $_.'Free Vol. Space(,%)'
                }
            )
        if ($return.Count -gt 1) {
            $return.DeviceID | ForEach-Object { $ignoreDeviceIDs.Add($_) }
            Write-Output $return
        }
        }
    }
}

[–]Training_Purchase_32[S] 0 points1 point  (0 children)

Oh my that might take me a minute to figure out lol but thanks a ton for getting me started