{"id":3027,"date":"2018-11-30T17:33:49","date_gmt":"2018-11-30T16:33:49","guid":{"rendered":"https:\/\/www.mariotti.de\/?p=3027"},"modified":"2018-11-30T17:33:49","modified_gmt":"2018-11-30T16:33:49","slug":"eventsource-per-powershell-selbst-anlegen","status":"publish","type":"post","link":"https:\/\/dev.mariotti.de\/?p=3027","title":{"rendered":"EventSource per PowerShell selbst anlegen"},"content":{"rendered":"<p>Die Windows PowerShell hat einige Cmdlets zum Windows EventLog wie z.B. New-EventLog, Write-EventLog, Get-EventLog, etc.<br \/>\nWas jedoch fehlt ist die M\u00f6glichkeit seine eigne EventSource anzulegen ohne EventSource DLL.<\/p>\n<p>Die Problematik l\u00e4sst sich jedoch \u00fcber folgendes kleines Skript l\u00f6sen welches eine neue EventSource anlegt.<\/p>\n<pre><code class=\"language-powershell\">$EventSourceName = \"MyPowerShellScript\"\nif ([System.Diagnostics.EventLog]::SourceExists($EventSourceName) -eq $false) {\n   Write-Host \"Creating event source [$EventSourceName] on event log [Application]\"\n   [System.Diagnostics.EventLog]::CreateEventSource(\"$EventSourceName\",'Application')\n} else { Write-Host \"Event source [$EventSourceName] is already registered\" }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In diesem Beitrag gibt es etwas Besipielcode der es erm\u00f6glich eine eigene Windows EventLog EventSource per PowerShell anzulegen, ohne dass man hierzu eine entsprechende DLL ben\u00f6tigt.<\/p>\n","protected":false},"author":2,"featured_media":2425,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-3027","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3027"}],"version-history":[{"count":0,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3027\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/media\/2425"}],"wp:attachment":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}