我想获取文件的内容。
文件格式如下
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,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
......
我要读取包含NVMe和Sata的Disk0MapForUefiBootOrder的值,
PciRoot(0x0)/Pci(0x1B,7D-F0-B6-71-B7-38-25-00)
PciRoot(0x0)/Pci(0x1B,00-00-00-00-00-00-00-00)
PciRoot(0x0)/Pci(0x17,0x0)
,并将其传递到输出文件。然后我必须按等级对其进行排序。
我尝试过,但是我只能阅读内容。但是我无法排名。
有人可以帮我吗?
$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