Click here to Skip to main content
15,888,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to exclude some information from physical disk and rank it. I tried this code, I can rank it, but I can not figure out when I want to exclude if "BusType=NVMe and Size > 32GB".

Anyone can help please,

What I have tried:

$Rank = @{
    'NVMe/SSD' = 1
    'SATA/SSD' = 2
    'SATA/HDD' = 3
    'RAID/SSD' = 4
    'RAID/HDD' = 4
    		
}
Get-PhysicalDisk |
    Select-Object DeviceID, FriendlyName, MediaType, BusType, Size | 
    Group-Object { '{0}/{1}' -f $_.BusType, $_.MediaType} |
    Where-Object { $Rank.Contains($_.Name) } |
    Sort-Object { $Rank[$_.Name] } |
    Select-Object -Expand Group | 
    Export-Csv 'Report.csv' -NoType
Posted
Updated 14-Aug-19 23:34pm

1 solution

You could use the -notlike operator, see examples here: Using PowerShell Operators[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900