{"id":820,"date":"2010-07-11T09:00:47","date_gmt":"2010-07-11T13:00:47","guid":{"rendered":"http:\/\/wehuberconsultingllc.com\/wordpress\/2010\/07\/11\/parsing-log-files-with-powershell\/"},"modified":"2010-07-11T10:12:22","modified_gmt":"2010-07-11T14:12:22","slug":"parsing-log-files-with-powershell","status":"publish","type":"post","link":"https:\/\/wehuberconsultingllc.com\/wordpress\/2010\/07\/11\/parsing-log-files-with-powershell\/","title":{"rendered":"Parsing log files with Powershell"},"content":{"rendered":"<p>I found myself wanting to parsing a log file to find out which domain was getting the most newsletters. There are a variety of ways you can do this. Typically I would use Excel but there were more than 65K lines to import so I had to use something different. For kicks I did it in Powershell and here is how I did it in three lines. The log file is a tab delimited file without a header line. The field we are going to count is called, \u00e2\u20ac\u0153RecipientDomain\u00e2\u20ac\u009d. <\/p>\n<p><pre class=\"brush: vb; title: ; notranslate\" title=\"\"> $header = &quot;ServerFQDN&quot;,&quot;ServerDomain&quot;,&quot;IPAddress&quot;,&quot;MailTime&quot;,&quot;ClientDomain&quot;,&quot;RecipientDomain&quot;,&quot;Sender&quot;,&quot;Recipient&quot;,&quot;MessageID&quot;,&quot;Status&quot;,&quot;User&quot;,&quot;Size&quot;,&quot;ClientFQDN&quot; \r\n$a = import-csv smtp-201007060000.csv -delimiter `t -header $header | where-object {($_.Status -eq &quot;RECV=OK&quot;) } \r\n$a | group-object -property RecipientDomain -noelement | sort -property @{Expression=&quot;Count&quot;;Descending=$true}, @{Expression=&quot;Name&quot;;Descending=$false} | Select-object -First 20 <\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found myself wanting to parsing a log file to find out which domain was getting the most newsletters. There are a variety of ways you can do this. Typically I would use Excel but there were more than 65K lines to import so I had to use something different. For kicks I did it &hellip; <a href=\"https:\/\/wehuberconsultingllc.com\/wordpress\/2010\/07\/11\/parsing-log-files-with-powershell\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Parsing log files with Powershell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[85,40],"tags":[],"class_list":["post-820","post","type-post","status-publish","format-standard","hentry","category-powershell","category-tips"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4iN3d-de","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/comments?post=820"}],"version-history":[{"count":5,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/820\/revisions"}],"predecessor-version":[{"id":826,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/820\/revisions\/826"}],"wp:attachment":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/media?parent=820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/categories?post=820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/tags?post=820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}