{"id":107,"date":"2007-04-10T11:00:00","date_gmt":"2007-04-10T19:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/04\/10\/updated-event-log-check\/"},"modified":"2007-04-10T11:00:00","modified_gmt":"2007-04-10T19:00:00","slug":"updated-event-log-check","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/","title":{"rendered":"Updated Event Log Check"},"content":{"rendered":"<p>A few months ago, I wrote an <a href=\"\/current\/2007\/2\/15\/powershell-quick-event-log.html\">entry<\/a> about using Powershell to look at recent event logs. Since then, I&#8217;ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve:<\/p>\n<p><font style=\"color: #0000ff\" face=\"lucida consolne\" color=\"#0000ff\" size=\"2\">Function Show-Logs {<br \/>Param([int]$iEntries) <\/font><\/p>\n<p><font style=\"color: #0000ff\" face=\"lucida consolne\" color=\"#0000ff\" size=\"2\">#default for number of entries is 5<br \/>if ($iEntries -lt 1) {$iEntries=5} <\/font><\/p>\n<p><font style=\"color: #0000ff\" face=\"lucida consolne\" color=\"#0000ff\" size=\"2\">foreach ($log in (get-eventlog -list -asString)) {<br \/>&nbsp;&nbsp; Write-Host $log -fore Green -back Black; Get-eventlog $log -newest $iEntries `<br \/>&nbsp;&nbsp; |select TimeGenerated,EntryType,Source,EventID,Message | more<br \/>&nbsp; }<br \/>}<\/font> <\/p>\n<p>I&#8217;ve added this function to my Powershell profile. The new syntax is Show-Logs [number-of-entries]. I&#8217;ve added code so that if you don&#8217;t specify the number of recent entries for each log, it will default to 5: <\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">if ($iEntries -lt 1) {$iEntries=5} <\/font><\/p>\n<p>Otherwise, the function will return the X number of recent event entries for each log file on your system.<\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:3f3cedd4-6bba-4cca-8815-53fc7665aa75\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\"><span class=\"sizeLess20\">Technorati tags: <\/span><a href=\"http:\/\/technorati.com\/tags\/PowerShell\" rel=\"tag\"><span class=\"sizeLess20\">PowerShell<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/Functions\" rel=\"tag\"><span class=\"sizeLess20\">Functions<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/EventLogs\" rel=\"tag\"><span class=\"sizeLess20\">EventLogs<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/Scripting\" rel=\"tag\"><span class=\"sizeLess20\">Scripting<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/Get-EventLog\" rel=\"tag\"><span class=\"sizeLess20\">Get-EventLog<\/span><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I&#8217;ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-windows-powershell"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Jeffery Hicks\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DEV SAPIEN Blog - Tools for IT Success\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Updated Event Log Check - DEV SAPIEN Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2007-04-10T19:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2007-04-10T19:00:00+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Updated Event Log Check - DEV SAPIEN Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#blogposting\",\"name\":\"Updated Event Log Check - DEV SAPIEN Blog\",\"headline\":\"Updated Event Log Check\",\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"},\"datePublished\":\"2007-04-10T11:00:00-07:00\",\"dateModified\":\"2007-04-10T11:00:00-07:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#webpage\"},\"articleSection\":\"Windows PowerShell\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/#listItem\",\"name\":\"Windows PowerShell\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/#listItem\",\"position\":2,\"name\":\"Windows PowerShell\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#listItem\",\"name\":\"Updated Event Log Check\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#listItem\",\"position\":3,\"name\":\"Updated Event Log Check\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/windows-powershell\\\/#listItem\",\"name\":\"Windows PowerShell\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/\",\"name\":\"Jeffery Hicks\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#webpage\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/\",\"name\":\"Updated Event Log Check - DEV SAPIEN Blog\",\"description\":\"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2007\\\/04\\\/10\\\/updated-event-log-check\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/jeffery-hicks\\\/#author\"},\"datePublished\":\"2007-04-10T11:00:00-07:00\",\"dateModified\":\"2007-04-10T11:00:00-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Updated Event Log Check - DEV SAPIEN Blog","description":"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.","canonical_url":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#blogposting","name":"Updated Event Log Check - DEV SAPIEN Blog","headline":"Updated Event Log Check","author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author"},"publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"},"datePublished":"2007-04-10T11:00:00-07:00","dateModified":"2007-04-10T11:00:00-07:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#webpage"},"isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#webpage"},"articleSection":"Windows PowerShell"},{"@type":"BreadcrumbList","@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/dev.sapien.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/#listItem","name":"Windows PowerShell"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/#listItem","position":2,"name":"Windows PowerShell","item":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#listItem","name":"Updated Event Log Check"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#listItem","position":3,"name":"Updated Event Log Check","previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/#listItem","name":"Windows PowerShell"}}]},{"@type":"Organization","@id":"https:\/\/dev.sapien.com\/blog\/#organization","name":"DEV SAPIEN Blog","description":"Tools for IT Success","url":"https:\/\/dev.sapien.com\/blog\/"},{"@type":"Person","@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author","url":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/","name":"Jeffery Hicks"},{"@type":"WebPage","@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#webpage","url":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/","name":"Updated Event Log Check - DEV SAPIEN Blog","description":"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/#breadcrumblist"},"author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author"},"creator":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/jeffery-hicks\/#author"},"datePublished":"2007-04-10T11:00:00-07:00","dateModified":"2007-04-10T11:00:00-07:00"},{"@type":"WebSite","@id":"https:\/\/dev.sapien.com\/blog\/#website","url":"https:\/\/dev.sapien.com\/blog\/","name":"DEV SAPIEN Blog","description":"Tools for IT Success","inLanguage":"en-US","publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"DEV SAPIEN Blog - Tools for IT Success","og:type":"article","og:title":"Updated Event Log Check - DEV SAPIEN Blog","og:description":"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve.","og:url":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/","article:published_time":"2007-04-10T19:00:00+00:00","article:modified_time":"2007-04-10T19:00:00+00:00","twitter:card":"summary_large_image","twitter:title":"Updated Event Log Check - DEV SAPIEN Blog","twitter:description":"A few months ago, I wrote an entry about using Powershell to look at recent event logs. Since then, I\u2019ve decided to make a minor improvement. The new function lets you specify the number of event logs to retrieve."},"aioseo_meta_data":{"post_id":"107","title":null,"description":null,"keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-08-28 14:18:34","updated":"2026-08-28 14:18:34"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/\" title=\"Windows PowerShell\">Windows PowerShell<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUpdated Event Log Check\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dev.sapien.com\/blog"},{"label":"Windows PowerShell","link":"https:\/\/dev.sapien.com\/blog\/topics\/windows-powershell\/"},{"label":"Updated Event Log Check","link":"https:\/\/dev.sapien.com\/blog\/2007\/04\/10\/updated-event-log-check\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}