LogParser で MBSA (/hf オプション)の結果を加工するためのヒント
以下のコマンドにて、スキャン結果をタブ区切りファイル(result.txt)に出力します。
#コマンドオプションの意味については、mbsacli.exe -hf -? として確認してください。
mbsacli.exe -hf -o tab -f result.txt
LogParser で処理させるSQL(MBSA_hf.sql)を作成。
SELECT [コンピュータ名] AS Computer, RTRIM ( EXTRACT_PREFIX( Computer , 0 , '(' )) AS HostName, EXTRACT_SUFFIX( REPLACE_STR ( Computer , ')' , '' ), 0 , '(' ) AS IP, [製品] AS Product, [セキュリティ情報] AS SecurityInformation, [文書番号] AS KnowledgeBase, [理由] AS Reason, [状態] AS State INTO result.html FROM result.txt ORDER BY Product,SecurityInformation
<LPHEADER> <HTML> <HEAD><TITLE>Microsoft Baseline Security Aalayzer 1.2.1 Summary</TITLE></HEAD> <H1>Microsoft Baseline Security Aalayzer 1.2.1 Summary</H1> <table BORDER="1" CELLPADDING="2" CELLSPACING="2"> <TR> <TH>製品</TH> <TH>セキュリティ情報</TH> <TH>文書番号</TH> <TH>状態</TH> <TH>コンピュータ</TH> <TH>ホスト名</TH> <TH>IP</TH> <TH>理由</TH> </TR> </LPHEADER> <LPBODY> <tr> <td>%Product%</td> <td><a href="http://www.microsoft.com/japan/technet/security/Bulletin/%SecurityInformation%">%SecurityInformation%</a></td> <td><a href="http://support.microsoft.com/kb/%KnowledgeBase%">%KnowledgeBase%</a></td> <td>%State%</td> <td>%Computer%</td> <td>%HostName%</td> <td>%IP%</td> <td>%Reason%</td> <td>%Reason%</td> </tr> </LPBODY> <LPFOOTER> </TABLE> </BODY> </HTML> </LPFOOTER>
実行コマンド
LogParser.exe -i:TSV file:MBSA_hf.sql -o:TPL -tpl:MBSA_hf.tpl -fixedSep:ON
- fixedSep:ON をつけないと、行がずれてしまいます。
このオプションをつけると、SQLファイルの↓のように記述するとエラーが出て実行できなくなり、ちょっと悩んでたりします。(手がないわけではないけどスマートに記述できないかなと)
COALESCE( [文書番号], 'N/A') AS KnowledgeBase,