私たちのVDI環境用のログオン監視製品からPowerShellのログを解析しようとしています。これは、ログファイルを書き込み、それがこの行書き込み:ログファイルから値を抽出します
2016-12-15T14:15:02.863 INFO (0908-0bd8) [LogonMonitor::LogSummary] Logon Time: 4.03 seconds
私は何をしようとしていることがちょうど「4.03」の文字列から解析し、値の配列に格納しているが。
$LogPath = "\\file-svr\Logs\"
$strings = Select-String -path $LogPath\*.txt -pattern "[LogonMonitor::LogSummary] Logon Time:" -AllMatches -simplematch
foreach ($string in $strings) {
$found = $string -match '\d\.'
if ($found) {
$time = $matches[1]
$array[$i] = $time
}
$i++
}
私はこれを行うより良い方法はありますか?
恐ろしく!私はこれを考えすぎた。どうもありがとうございます。これは完全に動作します – Koecerion
あなたは十分に近いです。どういたしまして。 –