<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Trigger a PowerShell Script from a Windows Event</title><link>http://blogs.technet.com/b/wincat/archive/2011/08/25/trigger-a-powershell-script-from-a-windows-event.aspx</link><description>Note: Portions of this blog are taken from an old blog post titled &amp;ldquo;Reference the Event That Triggered Your Task&amp;rdquo; 
 This example will demonstrate both how to trigger (launch) a PowerShell script from a specific Windows Event, AND pass parameters</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Trigger a PowerShell Script from a Windows Event</title><link>http://blogs.technet.com/b/wincat/archive/2011/08/25/trigger-a-powershell-script-from-a-windows-event.aspx#3487959</link><pubDate>Wed, 21 Mar 2012 18:18:46 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3487959</guid><dc:creator>Jeffrey S. Patton</dc:creator><description>&lt;p&gt;First off, AWESOME! I&amp;#39;ve been looking for a way to pass information from an event to a triggered script! This has saved me alot of time and effort.&lt;/p&gt;
&lt;p&gt;That said, I did have a few issues, the script as presented didn&amp;#39;t work for me. I don&amp;#39;t know what the difference would be, but for the record I&amp;#39;m running Windows 7 Enterprise x64 with Powershell 2.0&lt;/p&gt;
&lt;p&gt;The method that you used to cast eventparams as an xml didn&amp;#39;t work for me, so I changed that. This caused me to change how your if statement functioned as well. I also coudln&amp;#39;t get my output to display ina &amp;nbsp;popup, but since I want this stored in a file that didn&amp;#39;t matter to me. So here is the modified lower half of the script. I&amp;#39;ll most likely clean this up and make it look how most of my scripts look, but for the time being I know this works quite well.&lt;/p&gt;
&lt;p&gt;$eventParams = ([xml]$event.ToXml())&lt;/p&gt;
&lt;p&gt;if ($eventParams.Event.System.TimeCreated.SystemTime) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;$XMLEvent.event.eventdata.data |Select-Object -Property @{Label=&amp;#39;EventField&amp;#39;;Expression=&amp;quot;Name&amp;quot;}, @{Label=&amp;#39;EventData&amp;#39;;Expression=&amp;quot;#text&amp;quot;} |ConvertTo-Csv -NoTypeInformation |Out-File U:\Home\Desktop\appusage.csv -Append&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Thanks so much!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3487959" width="1" height="1"&gt;</description></item></channel></rss>