0

ログ ファイルのレジストリ コンテンツを検索するためのコードを探しています。具体的には:

Get-ItemProperty -path hklm:\system\currentcontrolset\enum\usbstor\*\* | select PSChildName

シリアル番号をリストします。シリアル番号ごとに、テキスト ログ ファイルを検索して、アイテムがいつ表示されるかを確認できるようにする必要があります。

これが私が今使っているものです:

Get-ItemProperty -path hklm:\system\currentcontrolset\enum\usbstor\*\* | select PSChildName | foreach-object {Get-Content C:\Windows\inf\setupapi.dev.log | select-string '$_.PSChildName' -context 1}

しかし、検索が機能しPSChildNameていません。何が欠けていますか?

4

1 に答える 1

0

|の原因だと思います $_.PSChildName を通じて何も送信していません。したがって、2つのソリューションのうちの1つを使用できます

解決策 1

Get-ItemProperty -path hklm:\system\currentcontrolset\enum\usbstor\*\* | select PSChildName | foreach-object {$P = $_.PSChildName ; Get-Content  C:\Windows\inf\setupapi.dev.log | select-string $P -SimpleMatch -context 1} 

解決策 2

$KeyListArray = @()
    Foreach($key in Get-ItemProperty -path hklm:\system\currentcontrolset\enum\usbstor\*\* | select PSChildName)
    {$KeyListArray +($key)}


foreach($PsChild in $KeyListArray)
{Get-Content C:\Windows\inf\setupapi.dev.log | select-string -Pattern "$PsChild" -context 1}
于 2012-07-19T22:16:57.727 に答える