我正在尝试从下面的类似字符串中提取日期和时间:
<![LOG[Inventory: Successfully sent report. Destination:mp:MP_SinvEndpoint, ID: {CFF6CD46-AEC7-4BFB-8B09-E7507346AAF6}, Timeout: 80640 minutes MsgMode: Signed, Not Encrypted]LOG]!><time="14:30:50.088+300" date="09-24-2013" component="InventoryAgent" context="" type="1" thread="4448" file="agentstate.cpp:2038">
我正在使用这些声明:
$Sinv = Select-String $env:windir\syswow64\ccm\logs\inventoryagent.log -pattern "SinvEndpoint" -SimpleMatch | select-object -last 1
$Hinv = Select-String $env:windir\syswow64\ccm\logs\inventoryagent.log -pattern "HinvEndpoint" -SimpleMatch | select-object -last 1
$DDR = Select-String $env:windir\syswow64\ccm\logs\inventoryagent.log -pattern "DdrEndpoint" -SimpleMatch | select-object -last 1
我试图确定每个最后一个条目的发生顺序(基于其字符串中的时间戳),然后我将相应地编写代码。