Filtering & counting result Debug-StorageSubSystem

Welcome Forums General PowerShell Q&A Filtering & counting result Debug-StorageSubSystem

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #59745

    Participant
    Points: 0
    Rank: Member

    Hi,

    We have a windows 2016 with the new storage spaces and I want now monitor the health of the pool.
    In powershell I can run: "Get-StorageSubSystem Cluster* | Debug-StorageSubSystem"
    and then I have a result (cfr beneath).
    I would like to filter only the "Severity: Critical" and count the result (eg "1").

    Can somebody help me? The (... | measure).count gives me a number but I can't filter.

    TIA

    Mario

    Severity: Critical

    Reason : xxx
    Recommendation : xxx
    Location : xxx
    Description : xxx

    Severity: Minor

    Reason : yyy
    Recommendation : yyy
    Location : yyy
    Description : yyy

  • #59751

    Participant
    Points: 160
    Helping Hand
    Rank: Participant

    You can get a count based on severity by using Group-Object:

    Get-StorageSubSystem Cluster* | Debug-StorageSubSystem | Group-Object -Property Severity -NoElement | Sort Count -Descending 
    

    You can also filter like this:

    $debug = Get-StorageSubSystem Cluster* | Debug-StorageSubSystem | Where {$_.Severity -eq 'Critical'}
    $debug.Count
    
    • #59763

      Participant
      Points: 0
      Rank: Member

      Thank you Rob!

      I will use
      (Get-StorageSubSystem Cluster* | Debug-StorageSubSystem | Where {$_.PerceivedSeverity -eq 'Critical'} | measure).count

      Apparently the object was
      https://msdn.microsoft.com/en-us/library/windows/desktop/dn889970(v=vs.85).aspx
      with the property PerceivedSeverity and not severity like it was onscreen.

      It took some time to detect the class but you have put me in the correct direction.
      Tx!

      Mario

The topic ‘Filtering & counting result Debug-StorageSubSystem’ is closed to new replies.