I want to get the contents of a file.
The format of file is like this
Disk0MapForUefiBootOrder
PciRoot(0x0)/Pci(0x14,0x0)
PciRoot(0x0)/Pci(0x1B,0x0)/Pci(0x0,0x0)/NVMe(0x1,7D-F0-B6-71-B7-38-25-00)
PciRoot(0x0)/Pci(0x1B,0x4)/Pci(0x0,0x0)/NVMe(0x1,00-00-00-00-00-00-00-00)
PciRoot(0x0)/Pci(0x17,0x0)/Sata(0x1,0xFFFF,0x0)
BBS(0xFFFF,,0x0)/PciRoot(0x0)/Pci(0x14,0x0)
Fast Charge
Disable
*Enable
......
I want to read the value of this Disk0MapForUefiBootOrder which contains NVMe and Sata, which are:
PciRoot(0x0)/Pci(0x1B,0x0)/Pci(0x0,0x0)/NVMe(0x1,7D-F0-B6-71-B7-38-25-00)
PciRoot(0x0)/Pci(0x1B,0x4)/Pci(0x0,0x0)/NVMe(0x1,00-00-00-00-00-00-00-00)
PciRoot(0x0)/Pci(0x17,0x0)/Sata(0x1,0xFFFF,0x0)
and pass it to the output file. Then I have to sort it with a rank.
I tried this, but I can only read the content. But I can not rank it.
Can anyone help me please?
$FileContents = Get-Content "D:\Boot\file.txt" | Select-String -Pattern "PciRoot" | Out-File D:\Boot\Out2 -Force
$FileContents
$Rank = @{
'NVMe' = 1
'Sata' = 2
}
$FileContents |
Where-Object { $Rank.Contains("NVMe" -and "Sata") } | Sort-Object {[int64]$_.Size} |
Sort-Object { $Rank["NVMe" -and "Sata"] }|
Export-Csv 'Output.csv' -NoType