Writing events with parameters using PowerShell
<!--[if lt IE 9]>
<![endif]-->
Comments
- Anonymous
April 07, 2016
Hi Kevin,This is exactly what I was looking for. What parameter do I need in the powershell script to create an event level of Error?Thanks,Ron- Anonymous
April 07, 2016
The comment has been removed- Anonymous
April 07, 2016
Hi Kevin,Perfect! Thanks,Ron
- Anonymous
- Anonymous
- Anonymous
April 11, 2016
Hello Kevin,Why does the event only show the data item in Event Viewer (General Properties), and yet if I go other events not created with this method, I see multiple data items in the general tab view?- Anonymous
April 11, 2016
I don't know. But I kinda like it. This way I can input whatever variables I want in param 1 (which will show up in the event view) and then dump in all kinds of stuff in other params which will be hidden.- Anonymous
December 05, 2016
Is there a limitation on the number of params you may use? I appear to be getting "cutoff" after param4.
- Anonymous
- Anonymous
- Anonymous
March 06, 2017
Hi.Thanks for the script.Do you have any idea how to update Event’s XML metadata with attributes?E.g. attribute "Name" in this exampleFilec:\temp\MyTestFile.txtSee tag and "Name" attribute below:https://blogs.technet.microsoft.com/askds/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer- Anonymous
April 03, 2017
I would LOVE to know this as well. Hoping it isn't one of those Param or Message dlls that are used...
- Anonymous
- Anonymous
March 19, 2017
Another Mr Holman saves the day again :) Thanks.Just made a slight mod to create warning or error events on the flyfunction CreateParamEvent ($evtID,$type,[array]$params) { If($type -eq 'information') { $id = New-Object System.Diagnostics.EventInstance($evtID,1); #INFORMATION EVENT }Elseif($type -eq 'warning') { $id = New-Object System.Diagnostics.EventInstance($evtID,1,2); #WARNING EVENT }Elseif($type -eq 'error') { $id = New-Object System.Diagnostics.EventInstance($evtID,1,1); #ERROR EVENT }Else {write-warning "Please specify Event type information / warning / error "} $evtObject = New-Object System.Diagnostics.EventLog; $evtObject.Log = $evtlog; $evtObject.Source = $source; $evtObject.WriteEvent($id, [array]$params) }