<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="http://www.codeplex.com/rss.xsl"?><rss version="2.0"><channel><title>PowerShell Eventing Library</title><link>http://www.codeplex.com/PSEventing/Project/ProjectRss.aspx</link><description>Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.</description><item><title>New Post: Add-EventHandler dictionary issue</title><link>http://www.codeplex.com/PSEventing/Thread/View.aspx?ThreadId=29416</link><description>&lt;div style="line-height: normal;"&gt;&lt;br&gt;
&lt;div style="border-right:medium none;padding-right:0.2em;border-top:#aaa 0.1em dotted;padding-left:0.2em;padding-bottom:0.2em;margin:1em 0em 2.5em 3em;border-left:medium none;padding-top:0.2em;border-bottom:#aaa 0.1em dotted;font-style:italic"&gt;&lt;br&gt;
&lt;p&gt;Ok, I looked at the source and it will be impossible to bind the same event name to the same ps variable more than once without completely re-writing the source code. I did resolve this, just needed to dynamically create my variable in the for loop so that each ps variable is unique.&lt;/p&gt;
&lt;p&gt;# dynamic variable index&lt;br&gt;
$StepIndex = 0&lt;/p&gt;
&lt;p&gt;foreach ($ApplicationEntry in $($Project.Applications).GetEnumerator())) &lt;br&gt;
{&lt;br&gt;
&amp;nbsp;...&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;nbsp;$New-Variable &amp;quot;Step$StepIndex&amp;quot; -value $MiscPackage.Steps.Get_Item(&amp;quot;Step XYZ&amp;quot;)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;# get a reference to the dynamic variable&lt;br&gt;
&amp;nbsp;$Step = (Get-Variable &amp;quot;Step$StepIndex&amp;quot; -ValueOnly)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;... do some stuff to the step ...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Add-EventHandler (Get-Variable &amp;quot;Step$StepIndex&amp;quot;) StepFailed { param($var) Write-Error &amp;quot;The step $($var.Value.Name) failed!&amp;quot; }&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;nbsp;$Step.Execute();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;# increment our step index by one&lt;br&gt;
&amp;nbsp;$StepIndex++&lt;br&gt;
}&lt;/p&gt;
&lt;p&gt;Write-Host &amp;quot;Waiting for events..&amp;quot; &lt;br&gt;
Do-Events $true&lt;/p&gt;
&lt;p&gt;cheers,&lt;br&gt;
joey&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;</description><author>JoeyBradshaw</author><pubDate>Wed, 11 Jun 2008 20:34:52 GMT</pubDate><guid isPermaLink="false">New Post: Add-EventHandler dictionary issue 20080611083452P</guid></item><item><title>New Post: Add-EventHandler dictionary issue</title><link>http://www.codeplex.com/PSEventing/Thread/View.aspx?ThreadId=29416</link><description>&lt;div style="line-height: normal;"&gt;&lt;p&gt;I'm wondering if there is a way to use PSEventing given my situation. In the code below you'll notice that in the foreach loop I attach and event handler during each iteration but this fails because the code for the Add-Eventhandler is a hashtable and you cannot add the same event name more than once. I'm hoping someone can provide me with more details on this line $events = @(read-event -wait) and what properties are avialable for each event that it returns. Is it possible to re-write Add-Eventhandler to use a unique event guid as the hashtables key rather than an event name?&lt;/p&gt;
&lt;p&gt;foreach ($ApplicationEntry in $($Project.Applications).GetEnumerator())) &lt;br&gt;
{&lt;br&gt;
&amp;nbsp;...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;$Step = $MiscPackage.Steps.Get_Item(&amp;quot;Step XYZ&amp;quot;) &lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;nbsp;Add-EventHandler (get-variable Step) StepFailed { param($var) Write-Error &amp;quot;The step $($var.Value.Name) failed!&amp;quot; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;$Step.Execute();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Write-Host &amp;quot;Waiting for events..&amp;quot; &lt;br&gt;
Do-Events $true&lt;/p&gt;
&lt;p&gt;thx, joey &lt;/p&gt;
&lt;/div&gt;</description><author>JoeyBradshaw</author><pubDate>Tue, 10 Jun 2008 23:59:11 GMT</pubDate><guid isPermaLink="false">New Post: Add-EventHandler dictionary issue 20080610115911P</guid></item><item><title>UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008)</title><link>http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919</link><description> _New Features_&lt;br /&gt;&lt;br /&gt;&amp;#42; Multiple named queue support and default queue with -QueueName parameter&lt;br /&gt;&amp;#42; Better COM support, window message pumping etc.&lt;br /&gt;&amp;#42; NoFlush &amp;#47; Peek parameter support for queue reading&lt;br /&gt;&amp;#42; Get-EventQueue command added for viewing queues and their message counts.&lt;br /&gt;&lt;br /&gt;_Changes_&lt;br /&gt;&lt;br /&gt;&amp;#42; Get-Event -&amp;#62; Read-Event&lt;br /&gt;&amp;#42; Connect-EventListener -&amp;#62; Connect-Event&lt;br /&gt;&amp;#42; Disconnect-EventListener -&amp;#62; Disconnect-Event&lt;br /&gt;&lt;br /&gt;see &amp;#91;url&amp;#58;foreground &amp;#47; background swappable downloads in powershell&amp;#124;http&amp;#58;&amp;#47;&amp;#47;www.nivot.org&amp;#47;2007&amp;#47;12&amp;#47;05&amp;#47;ForegroundBackgroundSwappableDownloadsInPowerShell.aspx&amp;#93; for an advanced example.&lt;br /&gt;</description><author></author><pubDate>Thu, 05 Jun 2008 17:40:48 GMT</pubDate><guid isPermaLink="false">UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008) 20080605054048P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Home&amp;version=52</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
&lt;a href="http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919"&gt;PSEventing 1.1&lt;/a&gt; Released
&lt;/h1&gt;Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.
&lt;br /&gt;&lt;h2&gt;
Important
&lt;/h2&gt;This is intended for PowerShell v1.0 only. PowerShell v2.0 CTP2 has introduced support for eventing with similarly named cmdlets, but with real-time (interrupt-based) event support. &lt;br /&gt;&lt;h2&gt;
New Features
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Multiple named queue support and default queue with -QueueName parameter&lt;/li&gt;&lt;li&gt;Better COM support, window message pumping etc.&lt;/li&gt;&lt;li&gt;NoFlush / Peek parameter support for queue reading&lt;/li&gt;&lt;li&gt;Get-EventQueue command added for viewing queues and their message counts.&lt;/li&gt;
&lt;/ul&gt;See &lt;a href="http://www.nivot.org/2007/12/05/ForegroundBackgroundSwappableDownloadsInPowerShell.aspx" class="externalLink"&gt;foreground / background swappable downloads in powershell&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; for an advanced example.&lt;br /&gt;&lt;h2&gt;
Cmdlet Name Changes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Get-Event -&amp;gt; Read-Event&lt;/li&gt;&lt;li&gt;Connect-EventListener -&amp;gt; Connect-Event&lt;/li&gt;&lt;li&gt;Disconnect-EventListener -&amp;gt; Disconnect-Event&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;
64 bit PowerShell Support
&lt;/h3&gt;To install for use with the 64bit version of PowerShell, please use the 64bit version of InstallUtil:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt;&amp;amp; &amp;quot;$env:windir\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe&amp;quot; nivot.powershell.eventing.dll&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
How does it work?
&lt;/h2&gt; &lt;br /&gt;Events in PowerShell - but how? Events in a .NET executable are generally raised and handled in realtime in an asynchronous fashion; at first glance, this doesn't seem possible with our favourite little shell. PowerShell lets us wire up scriptblocks to .NET events as handlers relatively easily, but unfortunately if the event is raised on a different thread (as is the case with WMI watchers, FileSystemWatchers and other asynchronous objects), there is no runspace available to execute our script. So, how do we get a runspace to execute a handler? Well, we ensure that we are in a running pipeline before processing events. This is achieved by disconnecting the process: we separate the occurance of events from the act of handling them.  How does this work in practice? Let's play with &lt;span class="codeInline"&gt;System.IO.FileSystemWatcher&lt;/span&gt; :&lt;br /&gt;&lt;h2&gt;
Example with FileSystemWatcher
&lt;/h2&gt; &lt;br /&gt;This example uses the Cmdlets directly to demonstrate how the Snap-In works; you may find it easier and more familiar to work with the simple wrapper functions supplied on the Releases page. See the bottom of this page to read about these functions, called &lt;span class="codeInline"&gt;Add-EventHandler&lt;/span&gt;, &lt;span class="codeInline"&gt;Remove-EventHandler&lt;/span&gt; and &lt;span class="codeInline"&gt;Do-Events&lt;/span&gt; respectively.&lt;br /&gt;&lt;h3&gt;
Step 1
&lt;/h3&gt;&lt;pre&gt;
1# Add-PSSnapin pseventing
 
2# $fsw = new-object system.io.filesystemwatcher
3# $fsw.Path = &amp;quot;c:\temp&amp;quot;
4# $fsw.EnableRaisingEvents = $true
&lt;/pre&gt;This loads our snap-in, creates a &lt;span class="codeInline"&gt;FileSystemWatcher&lt;/span&gt; instance assigned to the variable named &lt;span class="codeInline"&gt;fsw&lt;/span&gt; and tells it to keep an eye on our temp directory. So, what events can we watch? Well, before you go running to MSDN...&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 2
&lt;/h3&gt;&lt;pre&gt;
#5 Get-EventBinding fsw -IncludeUnboundEvents | Format-Table -Auto
 
VariableName EventName TypeName          Listening
------------ --------- --------          ---------
fsw          Changed   FileSystemWatcher     False
fsw          Created   FileSystemWatcher     False
fsw          Deleted   FileSystemWatcher     False
fsw          Disposed  FileSystemWatcher     False
fsw          Error     FileSystemWatcher     False
fsw          Renamed   FileSystemWatcher     False
&lt;/pre&gt;This command lets us examine what events this variable exposes. Note that I say &lt;i&gt;variable&lt;/i&gt;, and &lt;b&gt;not&lt;/b&gt; object. This is a running theme throughout this library - &lt;b&gt;all PSEventing Cmdlets only deal with PSVariable objects, or variable names&lt;/b&gt; so do not prefix your variable names with the $ symbol. This will end up passing the instance instead of the variable, which is not what we want. This is to keep the paradigm similar to other late-bound scripting languages, like vbscript; allowing direct object references would not have been very admin-friendly. Ok, so next, lets watch the &lt;span class="codeInline"&gt;Changed&lt;/span&gt; and &lt;span class="codeInline"&gt;Deleted&lt;/span&gt; events. Btw,  Event names are not case sensitive, unless you provide the &lt;span class="codeInline"&gt;-CaseSensitive&lt;/span&gt; SwitchParameter.&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 3
&lt;/h3&gt;&lt;pre&gt;
5# Connect-Event fsw changed,deleted
&lt;/pre&gt;From this moment on, every time something is changed or deleted in c:\temp, a &lt;span class="codeInline"&gt;PSEvent&lt;/span&gt; object is added to our background event queue, even if you're busy running some other script or doing an unrelated task! Lets perform some related activity:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 4
&lt;/h3&gt;&lt;pre&gt;
6# &amp;quot;foo&amp;quot; &amp;gt; c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
&lt;/pre&gt;Now, we've just created and deleted a file. You could have also gone out to explorer and created and deleted the file; all events are captured, not just those triggered from within powershell. How do we find out whap's happened, and act on this info? with the &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; cmdlet:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 5
&lt;/h3&gt;&lt;pre&gt;
8# $events = Read-Event
9# $events | Format-Table -Auto
 
Occurred            Source                                  Name    Args
--------            ------                                  ----    ----
5/9/2007 3:31:39 PM System.Management.Automation.PSVariable Changed System.IO.FileSystemEventArgs
5/9/2007 3:31:42 PM System.Management.Automation.PSVariable Deleted System.IO.FileSystemEventArgs
&lt;/pre&gt;Two events occured since we wired up the listener (or since we last called &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; since each call drains the queue). Lets have a look at the EventArgs for the first one:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 6
&lt;/h3&gt;&lt;pre&gt;
10# $events[0].Args | format-table -Auto
 
ChangeType FullPath        Name
---------- --------        ----
   Changed c:\temp\bar.txt bar.txt
&lt;/pre&gt;And there you have it! &lt;br /&gt; &lt;br /&gt;Download the 1.1 release and have a look at the &lt;span class="codeInline"&gt;sqlbackup.ps1&lt;/span&gt; example script for more advanced uses.&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
Included Cmdlets
&lt;/h2&gt; &lt;br /&gt;All cmdlets have -? help support, and you can also get more information via &lt;span class="codeInline"&gt;get-help about_pseventing&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Connect-Event&lt;/b&gt; : Start tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Disconnect-Event&lt;/b&gt; : Stop tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventBinding&lt;/b&gt; : Retrieve event binding information for variables&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-Variable] [&amp;lt;PSVariable[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-VariableName] [&amp;lt;String[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;i&gt;Hint : bind  or unbind all events at once for a variable&lt;/i&gt;&lt;br /&gt;&lt;pre&gt;
  1# $fsw = New-Object System.IO.FileSystemWatcher
  2# Get-EventBinding fsw -IncludeUnboundEvents | Connect-Event
&lt;/pre&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;New-Event&lt;/b&gt; : Create a custom event for insertion into the queue with an optional object payload&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;New-Event [-EventName] &amp;lt;String&amp;gt; [[-Data] [&amp;lt;PSObject&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Read-Event&lt;/b&gt; : Retrieve one or more PSEvent objects representing tracked .NET events that have been raised since the last invocation of this command.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Read-Event [-Wait [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [-NoFlush &amp;lt;SwitchParameter&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventQueue&lt;/b&gt; :  Shows information about the default queue and/or named queues.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventQueue [[-QueueName] &amp;lt;String[]&amp;gt;] [-ShowEmpty] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Start-KeyHandler&lt;/b&gt; : Start generating PSEvent objects for break (cltr+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Start-KeyHandler [-CaptureCtrlC [&amp;lt;SwitchParameter&amp;gt;]] [-CaptureKeys [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Stop-KeyHandler&lt;/b&gt; : Stop generating PSEvent objects for break (ctrl+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Stop-KeyHandler [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;Read some more &lt;a href="http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Syntax%20Hints&amp;amp;referringTitle=Home"&gt;Syntax Hints&lt;/a&gt; for a quick start.&lt;br /&gt; &lt;br /&gt;- Oisin Grehan / x0n&lt;br /&gt;
&lt;/div&gt;</description><author>oisin</author><pubDate>Thu, 05 Jun 2008 16:51:28 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080605045128P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Home&amp;version=51</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
&lt;a href="http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919"&gt;PSEventing 1.1&lt;/a&gt; Released
&lt;/h1&gt;Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.
&lt;br /&gt;&lt;h2&gt;
Important
&lt;/h2&gt;This is intended for PowerShell v1.0 only. PowerShell v2.0 CTP2 has introduced support for eventing with similarly named cmdlets, but with real-time (interrupt-based) event support. &lt;br /&gt;&lt;h2&gt;
New Features
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Multiple named queue support and default queue with -QueueName parameter&lt;/li&gt;&lt;li&gt;Better COM support, window message pumping etc.&lt;/li&gt;&lt;li&gt;NoFlush / Peek parameter support for queue reading&lt;/li&gt;&lt;li&gt;Get-EventQueue command added for viewing queues and their message counts.&lt;/li&gt;
&lt;/ul&gt;See &lt;a href="http://www.nivot.org/2007/12/05/ForegroundBackgroundSwappableDownloadsInPowerShell.aspx" class="externalLink"&gt;foreground / background swappable downloads in powershell&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; for an advanced example.&lt;br /&gt;&lt;h2&gt;
Cmdlet Name Changes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Get-Event -&amp;gt; Read-Event&lt;/li&gt;&lt;li&gt;Connect-Event -&amp;gt; Connect-Event&lt;/li&gt;&lt;li&gt;Disconnect-Event -&amp;gt; Disconnect-Event&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;
64 bit PowerShell Support
&lt;/h3&gt;To install for use with the 64bit version of PowerShell, please use the 64bit version of InstallUtil:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt;&amp;amp; &amp;quot;$env:windir\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe&amp;quot; nivot.powershell.eventing.dll&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
How does it work?
&lt;/h2&gt; &lt;br /&gt;Events in PowerShell - but how? Events in a .NET executable are generally raised and handled in realtime in an asynchronous fashion; at first glance, this doesn't seem possible with our favourite little shell. PowerShell lets us wire up scriptblocks to .NET events as handlers relatively easily, but unfortunately if the event is raised on a different thread (as is the case with WMI watchers, FileSystemWatchers and other asynchronous objects), there is no runspace available to execute our script. So, how do we get a runspace to execute a handler? Well, we ensure that we are in a running pipeline before processing events. This is achieved by disconnecting the process: we separate the occurance of events from the act of handling them.  How does this work in practice? Let's play with &lt;span class="codeInline"&gt;System.IO.FileSystemWatcher&lt;/span&gt; :&lt;br /&gt;&lt;h2&gt;
Example with FileSystemWatcher
&lt;/h2&gt; &lt;br /&gt;This example uses the Cmdlets directly to demonstrate how the Snap-In works; you may find it easier and more familiar to work with the simple wrapper functions supplied on the Releases page. See the bottom of this page to read about these functions, called &lt;span class="codeInline"&gt;Add-EventHandler&lt;/span&gt;, &lt;span class="codeInline"&gt;Remove-EventHandler&lt;/span&gt; and &lt;span class="codeInline"&gt;Do-Events&lt;/span&gt; respectively.&lt;br /&gt;&lt;h3&gt;
Step 1
&lt;/h3&gt;&lt;pre&gt;
1# Add-PSSnapin pseventing
 
2# $fsw = new-object system.io.filesystemwatcher
3# $fsw.Path = &amp;quot;c:\temp&amp;quot;
4# $fsw.EnableRaisingEvents = $true
&lt;/pre&gt;This loads our snap-in, creates a &lt;span class="codeInline"&gt;FileSystemWatcher&lt;/span&gt; instance assigned to the variable named &lt;span class="codeInline"&gt;fsw&lt;/span&gt; and tells it to keep an eye on our temp directory. So, what events can we watch? Well, before you go running to MSDN...&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 2
&lt;/h3&gt;&lt;pre&gt;
#5 Get-EventBinding fsw -IncludeUnboundEvents | Format-Table -Auto
 
VariableName EventName TypeName          Listening
------------ --------- --------          ---------
fsw          Changed   FileSystemWatcher     False
fsw          Created   FileSystemWatcher     False
fsw          Deleted   FileSystemWatcher     False
fsw          Disposed  FileSystemWatcher     False
fsw          Error     FileSystemWatcher     False
fsw          Renamed   FileSystemWatcher     False
&lt;/pre&gt;This command lets us examine what events this variable exposes. Note that I say &lt;i&gt;variable&lt;/i&gt;, and &lt;b&gt;not&lt;/b&gt; object. This is a running theme throughout this library - &lt;b&gt;all PSEventing Cmdlets only deal with PSVariable objects, or variable names&lt;/b&gt; so do not prefix your variable names with the $ symbol. This will end up passing the instance instead of the variable, which is not what we want. This is to keep the paradigm similar to other late-bound scripting languages, like vbscript; allowing direct object references would not have been very admin-friendly. Ok, so next, lets watch the &lt;span class="codeInline"&gt;Changed&lt;/span&gt; and &lt;span class="codeInline"&gt;Deleted&lt;/span&gt; events. Btw,  Event names are not case sensitive, unless you provide the &lt;span class="codeInline"&gt;-CaseSensitive&lt;/span&gt; SwitchParameter.&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 3
&lt;/h3&gt;&lt;pre&gt;
5# Connect-Event fsw changed,deleted
&lt;/pre&gt;From this moment on, every time something is changed or deleted in c:\temp, a &lt;span class="codeInline"&gt;PSEvent&lt;/span&gt; object is added to our background event queue, even if you're busy running some other script or doing an unrelated task! Lets perform some related activity:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 4
&lt;/h3&gt;&lt;pre&gt;
6# &amp;quot;foo&amp;quot; &amp;gt; c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
&lt;/pre&gt;Now, we've just created and deleted a file. You could have also gone out to explorer and created and deleted the file; all events are captured, not just those triggered from within powershell. How do we find out whap's happened, and act on this info? with the &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; cmdlet:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 5
&lt;/h3&gt;&lt;pre&gt;
8# $events = Read-Event
9# $events | Format-Table -Auto
 
Occurred            Source                                  Name    Args
--------            ------                                  ----    ----
5/9/2007 3:31:39 PM System.Management.Automation.PSVariable Changed System.IO.FileSystemEventArgs
5/9/2007 3:31:42 PM System.Management.Automation.PSVariable Deleted System.IO.FileSystemEventArgs
&lt;/pre&gt;Two events occured since we wired up the listener (or since we last called &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; since each call drains the queue). Lets have a look at the EventArgs for the first one:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 6
&lt;/h3&gt;&lt;pre&gt;
10# $events[0].Args | format-table -Auto
 
ChangeType FullPath        Name
---------- --------        ----
   Changed c:\temp\bar.txt bar.txt
&lt;/pre&gt;And there you have it! &lt;br /&gt; &lt;br /&gt;Download the 1.1 release and have a look at the &lt;span class="codeInline"&gt;sqlbackup.ps1&lt;/span&gt; example script for more advanced uses.&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
Included Cmdlets
&lt;/h2&gt; &lt;br /&gt;All cmdlets have -? help support, and you can also get more information via &lt;span class="codeInline"&gt;get-help about_pseventing&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Connect-Event&lt;/b&gt; : Start tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Disconnect-Event&lt;/b&gt; : Stop tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventBinding&lt;/b&gt; : Retrieve event binding information for variables&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-Variable] [&amp;lt;PSVariable[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-VariableName] [&amp;lt;String[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;i&gt;Hint : bind  or unbind all events at once for a variable&lt;/i&gt;&lt;br /&gt;&lt;pre&gt;
  1# $fsw = New-Object System.IO.FileSystemWatcher
  2# Get-EventBinding fsw -IncludeUnboundEvents | Connect-Event
&lt;/pre&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;New-Event&lt;/b&gt; : Create a custom event for insertion into the queue with an optional object payload&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;New-Event [-EventName] &amp;lt;String&amp;gt; [[-Data] [&amp;lt;PSObject&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Read-Event&lt;/b&gt; : Retrieve one or more PSEvent objects representing tracked .NET events that have been raised since the last invocation of this command.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Read-Event [-Wait [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [-NoFlush &amp;lt;SwitchParameter&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventQueue&lt;/b&gt; :  Shows information about the default queue and/or named queues.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventQueue [[-QueueName] &amp;lt;String[]&amp;gt;] [-ShowEmpty] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Start-KeyHandler&lt;/b&gt; : Start generating PSEvent objects for break (cltr+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Start-KeyHandler [-CaptureCtrlC [&amp;lt;SwitchParameter&amp;gt;]] [-CaptureKeys [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Stop-KeyHandler&lt;/b&gt; : Stop generating PSEvent objects for break (ctrl+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Stop-KeyHandler [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;Read some more &lt;a href="http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Syntax%20Hints&amp;amp;referringTitle=Home"&gt;Syntax Hints&lt;/a&gt; for a quick start.&lt;br /&gt; &lt;br /&gt;- Oisin Grehan / x0n&lt;br /&gt;
&lt;/div&gt;</description><author>oisin</author><pubDate>Thu, 05 Jun 2008 16:47:19 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080605044719P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Home&amp;version=50</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
&lt;a href="http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919"&gt;PSEventing 1.1&lt;/a&gt; Released
&lt;/h1&gt;Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.
&lt;br /&gt;&lt;h2&gt;
Important
&lt;/h2&gt;This is intended for PowerShell v1.0 only. PowerShell v2.0 CTP2 has introduced support for eventing with similarly named cmdlets, but with real-time (interrupt-based) event support. &lt;br /&gt;&lt;h2&gt;
New Features
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Multiple named queue support and default queue with -QueueName parameter&lt;/li&gt;&lt;li&gt;Better COM support, window message pumping etc.&lt;/li&gt;&lt;li&gt;NoFlush / Peek parameter support for queue reading&lt;/li&gt;&lt;li&gt;Get-EventQueue command added for viewing queues and their message counts.&lt;/li&gt;
&lt;/ul&gt;See &lt;a href="http://www.nivot.org/2007/12/05/ForegroundBackgroundSwappableDownloadsInPowerShell.aspx" class="externalLink"&gt;foreground / background swappable downloads in powershell&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; for an advanced example.&lt;br /&gt;&lt;h2&gt;
Cmdlet Name Changes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Get-Event -&amp;gt; Read-Event&lt;/li&gt;&lt;li&gt;Connect-Event -&amp;gt; Connect-Event&lt;/li&gt;&lt;li&gt;Disconnect-Event -&amp;gt; Disconnect-Event&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;
64 bit PowerShell Support
&lt;/h3&gt;To install for use with the 64bit version of PowerShell, please use the 64bit version of InstallUtil:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt;&amp;amp; &amp;quot;$env:windir\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe&amp;quot; nivot.powershell.eventing.dll&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
How does it work?
&lt;/h2&gt; &lt;br /&gt;Events in PowerShell - but how? Events in a .NET executable are generally raised and handled in realtime in an asynchronous fashion; at first glance, this doesn't seem possible with our favourite little shell. PowerShell lets us wire up scriptblocks to .NET events as handlers relatively easily, but unfortunately if the event is raised on a different thread (as is the case with WMI watchers, FileSystemWatchers and other asynchronous objects), there is no runspace available to execute our script. So, how do we get a runspace to execute a handler? Well, we ensure that we are in a running pipeline before processing events. This is achieved by disconnecting the process: we separate the occurance of events from the act of handling them.  How does this work in practice? Let's play with &lt;span class="codeInline"&gt;System.IO.FileSystemWatcher&lt;/span&gt; :&lt;br /&gt;&lt;h2&gt;
Example with FileSystemWatcher
&lt;/h2&gt; &lt;br /&gt;This example uses the Cmdlets directly to demonstrate how the Snap-In works; you may find it easier and more familiar to work with the simple wrapper functions supplied on the Releases page. See the bottom of this page to read about these functions, called &lt;span class="codeInline"&gt;Add-EventHandler&lt;/span&gt;, &lt;span class="codeInline"&gt;Remove-EventHandler&lt;/span&gt; and &lt;span class="codeInline"&gt;Do-Events&lt;/span&gt; respectively.&lt;br /&gt;&lt;h3&gt;
Step 1
&lt;/h3&gt;&lt;pre&gt;
1# Add-PSSnapin pseventing
 
2# $fsw = new-object system.io.filesystemwatcher
3# $fsw.Path = &amp;quot;c:\temp&amp;quot;
4# $fsw.EnableRaisingEvents = $true
&lt;/pre&gt;This loads our snap-in, creates a &lt;span class="codeInline"&gt;FileSystemWatcher&lt;/span&gt; instance assigned to the variable named &lt;span class="codeInline"&gt;fsw&lt;/span&gt; and tells it to keep an eye on our temp directory. So, what events can we watch? Well, before you go running to MSDN...&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 2
&lt;/h3&gt;&lt;pre&gt;
#5 Get-EventBinding fsw -IncludeUnboundEvents | Format-Table -Auto
 
VariableName EventName TypeName          Listening
------------ --------- --------          ---------
fsw          Changed   FileSystemWatcher     False
fsw          Created   FileSystemWatcher     False
fsw          Deleted   FileSystemWatcher     False
fsw          Disposed  FileSystemWatcher     False
fsw          Error     FileSystemWatcher     False
fsw          Renamed   FileSystemWatcher     False
&lt;/pre&gt;This command lets us examine what events this variable exposes. Note that I say &lt;i&gt;variable&lt;/i&gt;, and &lt;b&gt;not&lt;/b&gt; object. This is a running theme throughout this library - &lt;b&gt;all PSEventing Cmdlets only deal with PSVariable objects, or variable names&lt;/b&gt; so do not prefix your variable names with the $ symbol. This will end up passing the instance instead of the variable, which is not what we want. This is to keep the paradigm similar to other late-bound scripting languages, like vbscript; allowing direct object references would not have been very admin-friendly. Ok, so next, lets watch the &lt;span class="codeInline"&gt;Changed&lt;/span&gt; and &lt;span class="codeInline"&gt;Deleted&lt;/span&gt; events. Btw,  Event names are not case sensitive, unless you provide the &lt;span class="codeInline"&gt;-CaseSensitive&lt;/span&gt; SwitchParameter.&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 3
&lt;/h3&gt;&lt;pre&gt;
5# Connect-Event fsw changed,deleted
&lt;/pre&gt;From this moment on, every time something is changed or deleted in c:\temp, a &lt;span class="codeInline"&gt;PSEvent&lt;/span&gt; object is added to our background event queue, even if you're busy running some other script or doing an unrelated task! Lets perform some related activity:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 4
&lt;/h3&gt;&lt;pre&gt;
6# &amp;quot;foo&amp;quot; &amp;gt; c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
&lt;/pre&gt;Now, we've just created and deleted a file. You could have also gone out to explorer and created and deleted the file; all events are captured, not just those triggered from within powershell. How do we find out whap's happened, and act on this info? with the &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; cmdlet:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 5
&lt;/h3&gt;&lt;pre&gt;
8# $events = Read-Event
9# $events | Format-Table -Auto
 
Occurred            Source                                  Name    Args
--------            ------                                  ----    ----
5/9/2007 3:31:39 PM System.Management.Automation.PSVariable Changed System.IO.FileSystemEventArgs
5/9/2007 3:31:42 PM System.Management.Automation.PSVariable Deleted System.IO.FileSystemEventArgs
&lt;/pre&gt;Two events occured since we wired up the listener (or since we last called &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; since each call drains the queue). Lets have a look at the EventArgs for the first one:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 6
&lt;/h3&gt;&lt;pre&gt;
10# $events[0].Args | format-table -Auto
 
ChangeType FullPath        Name
---------- --------        ----
   Changed c:\temp\bar.txt bar.txt
&lt;/pre&gt;And there you have it! &lt;br /&gt; &lt;br /&gt;Download the 1.1 release and have a look at the &lt;span class="codeInline"&gt;sqlbackup.ps1&lt;/span&gt; example script for more advanced uses.&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
Included Cmdlets
&lt;/h2&gt; &lt;br /&gt;All cmdlets have -? help support, and you can also get more information via &lt;span class="codeInline"&gt;get-help about_pseventing&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Connect-Event&lt;/b&gt; : Start tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Disconnect-Event&lt;/b&gt; : Stop tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventBinding&lt;/b&gt; : Retrieve event binding information for variables&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-Variable] [&amp;lt;PSVariable[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-VariableName] [&amp;lt;String[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;i&gt;Hint : bind  or unbind all events at once for a variable&lt;/i&gt;&lt;br /&gt;&lt;pre&gt;
  1# $fsw = New-Object System.IO.FileSystemWatcher
  2# Get-EventBinding fsw -IncludeUnboundEvents | Connect-Event
&lt;/pre&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;New-Event&lt;/b&gt; : Create a custom event for insertion into the queue with an optional object payload&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;New-Event [-EventName] &amp;lt;String&amp;gt; [[-Data] [&amp;lt;PSObject&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Read-Event&lt;/b&gt; : Retrieve one or more PSEvent objects representing tracked .NET events that have been raised since the last invocation of this command.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Read-Event [-Wait [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [-NoFlush &amp;lt;SwitchParameter&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Start-KeyHandler&lt;/b&gt; : Start generating PSEvent objects for break (cltr+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Start-KeyHandler [-CaptureCtrlC [&amp;lt;SwitchParameter&amp;gt;]] [-CaptureKeys [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Stop-KeyHandler&lt;/b&gt; : Stop generating PSEvent objects for break (ctrl+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Stop-KeyHandler [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;Read some more &lt;a href="http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Syntax%20Hints&amp;amp;referringTitle=Home"&gt;Syntax Hints&lt;/a&gt; for a quick start.&lt;br /&gt; &lt;br /&gt;- Oisin Grehan / x0n&lt;br /&gt;
&lt;/div&gt;</description><author>oisin</author><pubDate>Thu, 05 Jun 2008 16:45:37 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080605044537P</guid></item><item><title>Source code checked in</title><link>http://www.codeplex.com/PSEventing/SourceControl/ListDownloadableCommits.aspx</link><description>updated scripts for 1.1</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 19:05:31 GMT</pubDate><guid isPermaLink="false">Source code checked in 20080604070531P</guid></item><item><title>UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008)</title><link>http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919</link><description> _New Features_&lt;br /&gt;&lt;br /&gt;&amp;#42; Multiple named queue support and default queue with -QueueName parameter&lt;br /&gt;&amp;#42; Better COM support, window message pumping etc.&lt;br /&gt;&amp;#42; NoFlush &amp;#47; Peek parameter support for queue reading&lt;br /&gt;&amp;#42; Get-EventQueue command added for viewing queues and their message counts.&lt;br /&gt;&lt;br /&gt;_Changes_&lt;br /&gt;&lt;br /&gt;&amp;#42; Get-Event -&amp;#62; Read-Event&lt;br /&gt;&amp;#42; Connect-EventListener -&amp;#62; Connect-Event&lt;br /&gt;&amp;#42; Disconnect-EventListener -&amp;#62; Disconnect-Event&lt;br /&gt;&lt;br /&gt;see &amp;#91;url&amp;#58;foreground &amp;#47; background swappable downloads in powershell&amp;#124;http&amp;#58;&amp;#47;&amp;#47;www.nivot.org&amp;#47;2007&amp;#47;12&amp;#47;05&amp;#47;ForegroundBackgroundSwappableDownloadsInPowerShell.aspx&amp;#93; for an advanced example.&lt;br /&gt;</description><author></author><pubDate>Wed, 04 Jun 2008 18:58:32 GMT</pubDate><guid isPermaLink="false">UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008) 20080604065832P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Home&amp;version=49</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
&lt;a href="http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919"&gt;PSEventing 1.1&lt;/a&gt; Released
&lt;/h1&gt;Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.
&lt;br /&gt;&lt;h2&gt;
Important
&lt;/h2&gt;This is intended for PowerShell v1.0 only. PowerShell v2.0 CTP2 has introduced support for eventing with similarly named cmdlets, but with real-time (interrupt-based) event support. &lt;br /&gt;&lt;h2&gt;
New Features
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Multiple named queue support and default queue with -QueueName parameter&lt;/li&gt;&lt;li&gt;Better COM support, window message pumping etc.&lt;/li&gt;&lt;li&gt;NoFlush / Peek parameter support for queue reading&lt;/li&gt;&lt;li&gt;read-EventQueue command added for viewing queues and their message counts.&lt;/li&gt;
&lt;/ul&gt;See &lt;a href="http://www.nivot.org/2007/12/05/ForegroundBackgroundSwappableDownloadsInPowerShell.aspx" class="externalLink"&gt;foreground / background swappable downloads in powershell&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; for an advanced example.&lt;br /&gt;&lt;h2&gt;
Cmdlet Name Changes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Get-Event -&amp;gt; Read-Event&lt;/li&gt;&lt;li&gt;Connect-Event -&amp;gt; Connect-Event&lt;/li&gt;&lt;li&gt;Disconnect-Event -&amp;gt; Disconnect-Event&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;
64 bit PowerShell Support
&lt;/h3&gt;To install for use with the 64bit version of PowerShell, please use the 64bit version of InstallUtil:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt;&amp;amp; &amp;quot;$env:windir\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe&amp;quot; nivot.powershell.eventing.dll&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
How does it work?
&lt;/h2&gt; &lt;br /&gt;Events in PowerShell - but how? Events in a .NET executable are generally raised and handled in realtime in an asynchronous fashion; at first glance, this doesn't seem possible with our favourite little shell. PowerShell lets us wire up scriptblocks to .NET events as handlers relatively easily, but unfortunately if the event is raised on a different thread (as is the case with WMI watchers, FileSystemWatchers and other asynchronous objects), there is no runspace available to execute our script. So, how do we get a runspace to execute a handler? Well, we ensure that we are in a running pipeline before processing events. This is achieved by disconnecting the process: we separate the occurance of events from the act of handling them.  How does this work in practice? Let's play with &lt;span class="codeInline"&gt;System.IO.FileSystemWatcher&lt;/span&gt; :&lt;br /&gt;&lt;h2&gt;
Example with FileSystemWatcher
&lt;/h2&gt; &lt;br /&gt;This example uses the Cmdlets directly to demonstrate how the Snap-In works; you may find it easier and more familiar to work with the simple wrapper functions supplied on the Releases page. See the bottom of this page to read about these functions, called &lt;span class="codeInline"&gt;Add-EventHandler&lt;/span&gt;, &lt;span class="codeInline"&gt;Remove-EventHandler&lt;/span&gt; and &lt;span class="codeInline"&gt;Do-Events&lt;/span&gt; respectively.&lt;br /&gt;&lt;h3&gt;
Step 1
&lt;/h3&gt;&lt;pre&gt;
1# Add-PSSnapin pseventing
 
2# $fsw = new-object system.io.filesystemwatcher
3# $fsw.Path = &amp;quot;c:\temp&amp;quot;
4# $fsw.EnableRaisingEvents = $true
&lt;/pre&gt;This loads our snap-in, creates a &lt;span class="codeInline"&gt;FileSystemWatcher&lt;/span&gt; instance assigned to the variable named &lt;span class="codeInline"&gt;fsw&lt;/span&gt; and tells it to keep an eye on our temp directory. So, what events can we watch? Well, before you go running to MSDN...&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 2
&lt;/h3&gt;&lt;pre&gt;
#5 Get-EventBinding fsw -IncludeUnboundEvents | Format-Table -Auto
 
VariableName EventName TypeName          Listening
------------ --------- --------          ---------
fsw          Changed   FileSystemWatcher     False
fsw          Created   FileSystemWatcher     False
fsw          Deleted   FileSystemWatcher     False
fsw          Disposed  FileSystemWatcher     False
fsw          Error     FileSystemWatcher     False
fsw          Renamed   FileSystemWatcher     False
&lt;/pre&gt;This command lets us examine what events this variable exposes. Note that I say &lt;i&gt;variable&lt;/i&gt;, and &lt;b&gt;not&lt;/b&gt; object. This is a running theme throughout this library - &lt;b&gt;all PSEventing Cmdlets only deal with PSVariable objects, or variable names&lt;/b&gt; so do not prefix your variable names with the $ symbol. This will end up passing the instance instead of the variable, which is not what we want. This is to keep the paradigm similar to other late-bound scripting languages, like vbscript; allowing direct object references would not have been very admin-friendly. Ok, so next, lets watch the &lt;span class="codeInline"&gt;Changed&lt;/span&gt; and &lt;span class="codeInline"&gt;Deleted&lt;/span&gt; events. Btw,  Event names are not case sensitive, unless you provide the &lt;span class="codeInline"&gt;-CaseSensitive&lt;/span&gt; SwitchParameter.&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 3
&lt;/h3&gt;&lt;pre&gt;
5# Connect-Event fsw changed,deleted
&lt;/pre&gt;From this moment on, every time something is changed or deleted in c:\temp, a &lt;span class="codeInline"&gt;PSEvent&lt;/span&gt; object is added to our background event queue, even if you're busy running some other script or doing an unrelated task! Lets perform some related activity:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 4
&lt;/h3&gt;&lt;pre&gt;
6# &amp;quot;foo&amp;quot; &amp;gt; c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
&lt;/pre&gt;Now, we've just created and deleted a file. You could have also gone out to explorer and created and deleted the file; all events are captured, not just those triggered from within powershell. How do we find out whap's happened, and act on this info? with the &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; cmdlet:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 5
&lt;/h3&gt;&lt;pre&gt;
8# $events = Read-Event
9# $events | Format-Table -Auto
 
Occurred            Source                                  Name    Args
--------            ------                                  ----    ----
5/9/2007 3:31:39 PM System.Management.Automation.PSVariable Changed System.IO.FileSystemEventArgs
5/9/2007 3:31:42 PM System.Management.Automation.PSVariable Deleted System.IO.FileSystemEventArgs
&lt;/pre&gt;Two events occured since we wired up the listener (or since we last called &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; since each call drains the queue). Lets have a look at the EventArgs for the first one:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 6
&lt;/h3&gt;&lt;pre&gt;
10# $events[0].Args | format-table -Auto
 
ChangeType FullPath        Name
---------- --------        ----
   Changed c:\temp\bar.txt bar.txt
&lt;/pre&gt;And there you have it! &lt;br /&gt; &lt;br /&gt;Download the 1.1 release and have a look at the &lt;span class="codeInline"&gt;sqlbackup.ps1&lt;/span&gt; example script for more advanced uses.&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
Included Cmdlets
&lt;/h2&gt; &lt;br /&gt;All cmdlets have -? help support, and you can also get more information via &lt;span class="codeInline"&gt;get-help about_pseventing&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Connect-Event&lt;/b&gt; : Start tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Disconnect-Event&lt;/b&gt; : Stop tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventBinding&lt;/b&gt; : Retrieve event binding information for variables&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-Variable] [&amp;lt;PSVariable[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-VariableName] [&amp;lt;String[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;i&gt;Hint : bind  or unbind all events at once for a variable&lt;/i&gt;&lt;br /&gt;&lt;pre&gt;
  1# $fsw = New-Object System.IO.FileSystemWatcher
  2# Get-EventBinding fsw -IncludeUnboundEvents | Connect-Event
&lt;/pre&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;New-Event&lt;/b&gt; : Create a custom event for insertion into the queue with an optional object payload&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;New-Event [-EventName] &amp;lt;String&amp;gt; [[-Data] [&amp;lt;PSObject&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Read-Event&lt;/b&gt; : Retrieve one or more PSEvent objects representing tracked .NET events that have been raised since the last invocation of this command.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Read-Event [-Wait [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [-NoFlush &amp;lt;SwitchParameter&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Start-KeyHandler&lt;/b&gt; : Start generating PSEvent objects for break (cltr+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Start-KeyHandler [-CaptureCtrlC [&amp;lt;SwitchParameter&amp;gt;]] [-CaptureKeys [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Stop-KeyHandler&lt;/b&gt; : Stop generating PSEvent objects for break (ctrl+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Stop-KeyHandler [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;Read some more &lt;a href="http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Syntax%20Hints&amp;amp;referringTitle=Home"&gt;Syntax Hints&lt;/a&gt; for a quick start.&lt;br /&gt; &lt;br /&gt;- Oisin Grehan / x0n&lt;br /&gt;
&lt;/div&gt;</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 18:19:31 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080604061931P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Home&amp;version=48</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
&lt;a href="http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919"&gt;PSEventing 1.1&lt;/a&gt; Released
&lt;/h1&gt;Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.
&lt;br /&gt;&lt;h2&gt;
Important
&lt;/h2&gt;This is intended for PowerShell v1.0 only. PowerShell v2.0 CTP2 has introduced support for eventing with similarly named cmdlets, but with real-time (interrupt-based) event support. See &lt;a href="http://www.nivot.org/2007/12/05/ForegroundBackgroundSwappableDownloadsInPowerShell.aspx" class="externalLink"&gt;foreground / background swappable downloads in powershell&lt;span class="externalLinkIcon"&gt;&lt;/span&gt;&lt;/a&gt; for an advanced example.&lt;br /&gt;&lt;h2&gt;
New Features
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Multiple named queue support and default queue with -QueueName parameter&lt;/li&gt;&lt;li&gt;Better COM support, window message pumping etc.&lt;/li&gt;&lt;li&gt;NoFlush / Peek parameter support for queue reading&lt;/li&gt;&lt;li&gt;read-EventQueue command added for viewing queues and their message counts.&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;
Cmdlet Name Changes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Get-Event -&amp;gt; Read-Event&lt;/li&gt;&lt;li&gt;Connect-Event -&amp;gt; Connect-Event&lt;/li&gt;&lt;li&gt;Disconnect-Event -&amp;gt; Disconnect-Event&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;
64 bit PowerShell Support
&lt;/h3&gt;To install for use with the 64bit version of PowerShell, please use the 64bit version of InstallUtil:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt;&amp;amp; &amp;quot;$env:windir\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe&amp;quot; nivot.powershell.eventing.dll&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
How does it work?
&lt;/h2&gt; &lt;br /&gt;Events in PowerShell - but how? Events in a .NET executable are generally raised and handled in realtime in an asynchronous fashion; at first glance, this doesn't seem possible with our favourite little shell. PowerShell lets us wire up scriptblocks to .NET events as handlers relatively easily, but unfortunately if the event is raised on a different thread (as is the case with WMI watchers, FileSystemWatchers and other asynchronous objects), there is no runspace available to execute our script. So, how do we get a runspace to execute a handler? Well, we ensure that we are in a running pipeline before processing events. This is achieved by disconnecting the process: we separate the occurance of events from the act of handling them.  How does this work in practice? Let's play with &lt;span class="codeInline"&gt;System.IO.FileSystemWatcher&lt;/span&gt; :&lt;br /&gt;&lt;h2&gt;
Example with FileSystemWatcher
&lt;/h2&gt; &lt;br /&gt;This example uses the Cmdlets directly to demonstrate how the Snap-In works; you may find it easier and more familiar to work with the simple wrapper functions supplied on the Releases page. See the bottom of this page to read about these functions, called &lt;span class="codeInline"&gt;Add-EventHandler&lt;/span&gt;, &lt;span class="codeInline"&gt;Remove-EventHandler&lt;/span&gt; and &lt;span class="codeInline"&gt;Do-Events&lt;/span&gt; respectively.&lt;br /&gt;&lt;h3&gt;
Step 1
&lt;/h3&gt;&lt;pre&gt;
1# Add-PSSnapin pseventing
 
2# $fsw = new-object system.io.filesystemwatcher
3# $fsw.Path = &amp;quot;c:\temp&amp;quot;
4# $fsw.EnableRaisingEvents = $true
&lt;/pre&gt;This loads our snap-in, creates a &lt;span class="codeInline"&gt;FileSystemWatcher&lt;/span&gt; instance assigned to the variable named &lt;span class="codeInline"&gt;fsw&lt;/span&gt; and tells it to keep an eye on our temp directory. So, what events can we watch? Well, before you go running to MSDN...&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 2
&lt;/h3&gt;&lt;pre&gt;
#5 Get-EventBinding fsw -IncludeUnboundEvents | Format-Table -Auto
 
VariableName EventName TypeName          Listening
------------ --------- --------          ---------
fsw          Changed   FileSystemWatcher     False
fsw          Created   FileSystemWatcher     False
fsw          Deleted   FileSystemWatcher     False
fsw          Disposed  FileSystemWatcher     False
fsw          Error     FileSystemWatcher     False
fsw          Renamed   FileSystemWatcher     False
&lt;/pre&gt;This command lets us examine what events this variable exposes. Note that I say &lt;i&gt;variable&lt;/i&gt;, and &lt;b&gt;not&lt;/b&gt; object. This is a running theme throughout this library - &lt;b&gt;all PSEventing Cmdlets only deal with PSVariable objects, or variable names&lt;/b&gt; so do not prefix your variable names with the $ symbol. This will end up passing the instance instead of the variable, which is not what we want. This is to keep the paradigm similar to other late-bound scripting languages, like vbscript; allowing direct object references would not have been very admin-friendly. Ok, so next, lets watch the &lt;span class="codeInline"&gt;Changed&lt;/span&gt; and &lt;span class="codeInline"&gt;Deleted&lt;/span&gt; events. Btw,  Event names are not case sensitive, unless you provide the &lt;span class="codeInline"&gt;-CaseSensitive&lt;/span&gt; SwitchParameter.&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 3
&lt;/h3&gt;&lt;pre&gt;
5# Connect-Event fsw changed,deleted
&lt;/pre&gt;From this moment on, every time something is changed or deleted in c:\temp, a &lt;span class="codeInline"&gt;PSEvent&lt;/span&gt; object is added to our background event queue, even if you're busy running some other script or doing an unrelated task! Lets perform some related activity:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 4
&lt;/h3&gt;&lt;pre&gt;
6# &amp;quot;foo&amp;quot; &amp;gt; c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
&lt;/pre&gt;Now, we've just created and deleted a file. You could have also gone out to explorer and created and deleted the file; all events are captured, not just those triggered from within powershell. How do we find out whap's happened, and act on this info? with the &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; cmdlet:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 5
&lt;/h3&gt;&lt;pre&gt;
8# $events = Read-Event
9# $events | Format-Table -Auto
 
Occurred            Source                                  Name    Args
--------            ------                                  ----    ----
5/9/2007 3:31:39 PM System.Management.Automation.PSVariable Changed System.IO.FileSystemEventArgs
5/9/2007 3:31:42 PM System.Management.Automation.PSVariable Deleted System.IO.FileSystemEventArgs
&lt;/pre&gt;Two events occured since we wired up the listener (or since we last called &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; since each call drains the queue). Lets have a look at the EventArgs for the first one:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 6
&lt;/h3&gt;&lt;pre&gt;
10# $events[0].Args | format-table -Auto
 
ChangeType FullPath        Name
---------- --------        ----
   Changed c:\temp\bar.txt bar.txt
&lt;/pre&gt;And there you have it! &lt;br /&gt; &lt;br /&gt;Download the 1.1 release and have a look at the &lt;span class="codeInline"&gt;sqlbackup.ps1&lt;/span&gt; example script for more advanced uses.&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
Included Cmdlets
&lt;/h2&gt; &lt;br /&gt;All cmdlets have -? help support, and you can also get more information via &lt;span class="codeInline"&gt;get-help about_pseventing&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Connect-Event&lt;/b&gt; : Start tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Disconnect-Event&lt;/b&gt; : Stop tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventBinding&lt;/b&gt; : Retrieve event binding information for variables&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-Variable] [&amp;lt;PSVariable[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-VariableName] [&amp;lt;String[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;i&gt;Hint : bind  or unbind all events at once for a variable&lt;/i&gt;&lt;br /&gt;&lt;pre&gt;
  1# $fsw = New-Object System.IO.FileSystemWatcher
  2# Get-EventBinding fsw -IncludeUnboundEvents | Connect-Event
&lt;/pre&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;New-Event&lt;/b&gt; : Create a custom event for insertion into the queue with an optional object payload&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;New-Event [-EventName] &amp;lt;String&amp;gt; [[-Data] [&amp;lt;PSObject&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Read-Event&lt;/b&gt; : Retrieve one or more PSEvent objects representing tracked .NET events that have been raised since the last invocation of this command.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Read-Event [-Wait [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [-NoFlush &amp;lt;SwitchParameter&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Start-KeyHandler&lt;/b&gt; : Start generating PSEvent objects for break (cltr+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Start-KeyHandler [-CaptureCtrlC [&amp;lt;SwitchParameter&amp;gt;]] [-CaptureKeys [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Stop-KeyHandler&lt;/b&gt; : Stop generating PSEvent objects for break (ctrl+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Stop-KeyHandler [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;Read some more &lt;a href="http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Syntax%20Hints&amp;amp;referringTitle=Home"&gt;Syntax Hints&lt;/a&gt; for a quick start.&lt;br /&gt; &lt;br /&gt;- Oisin Grehan / x0n&lt;br /&gt;
&lt;/div&gt;</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 18:19:07 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080604061907P</guid></item><item><title>UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008)</title><link>http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919</link><description> _New Features_&lt;br /&gt;&lt;br /&gt;&amp;#42; Multiple named queue support and default queue with -QueueName parameter&lt;br /&gt;&amp;#42; Better COM support, window message pumping etc.&lt;br /&gt;&amp;#42; NoFlush &amp;#47; Peek parameter support for queue reading&lt;br /&gt;&amp;#42; Get-EventQueue command added for viewing queues and their message counts.&lt;br /&gt;&lt;br /&gt;_Changes_&lt;br /&gt;&lt;br /&gt;&amp;#42; Get-Event -&amp;#62; Read-Event&lt;br /&gt;&amp;#42; Connect-EventListener -&amp;#62; Connect-Event&lt;br /&gt;&amp;#42; Disconnect-EventListener -&amp;#62; Disconnect-Event&lt;br /&gt;&lt;br /&gt;see &amp;#91;url&amp;#58;foreground &amp;#47; background swappable downloads in powershell&amp;#124;http&amp;#58;&amp;#47;&amp;#47;www.nivot.org&amp;#47;2007&amp;#47;12&amp;#47;05&amp;#47;ForegroundBackgroundSwappableDownloadsInPowerShell.aspx&amp;#93; for an advanced example.&lt;br /&gt;</description><author></author><pubDate>Wed, 04 Jun 2008 18:16:55 GMT</pubDate><guid isPermaLink="false">UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008) 20080604061655P</guid></item><item><title>UPDATED WIKI: Home</title><link>http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Home&amp;version=47</link><description>&lt;div class="wikidoc"&gt;
&lt;h1&gt;
&lt;a href="http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919"&gt;PSEventing 1.1&lt;/a&gt; Released
&lt;/h1&gt;Trap and respond to synchronous &amp;#38; asynchronous .NET, COM and WMI events within your powershell scripts with this easy to use suite of cmdlets. Compatible with PowerShell 1.0 and 2.0CTP.
&lt;br /&gt;&lt;h2&gt;
Important
&lt;/h2&gt;This is intended for PowerShell v1.0 only. PowerShell v2.0 CTP2 has introduced support for eventing with similarly named cmdlets, but with real-time (interrupt-based) event support.&lt;br /&gt;&lt;h2&gt;
New Features
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Multiple named queue support and default queue with -QueueName parameter&lt;/li&gt;&lt;li&gt;Better COM support, window message pumping etc.&lt;/li&gt;&lt;li&gt;NoFlush / Peek parameter support for queue reading&lt;/li&gt;&lt;li&gt;read-EventQueue command added for viewing queues and their message counts.&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;
Cmdlet Name Changes
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Get-Event -&amp;gt; Read-Event&lt;/li&gt;&lt;li&gt;Connect-Event -&amp;gt; Connect-Event&lt;/li&gt;&lt;li&gt;Disconnect-Event -&amp;gt; Disconnect-Event&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;
64 bit PowerShell Support
&lt;/h3&gt;To install for use with the 64bit version of PowerShell, please use the 64bit version of InstallUtil:&lt;br /&gt; &lt;br /&gt;&lt;span class="codeInline"&gt;&amp;amp; &amp;quot;$env:windir\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe&amp;quot; nivot.powershell.eventing.dll&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
How does it work?
&lt;/h2&gt; &lt;br /&gt;Events in PowerShell - but how? Events in a .NET executable are generally raised and handled in realtime in an asynchronous fashion; at first glance, this doesn't seem possible with our favourite little shell. PowerShell lets us wire up scriptblocks to .NET events as handlers relatively easily, but unfortunately if the event is raised on a different thread (as is the case with WMI watchers, FileSystemWatchers and other asynchronous objects), there is no runspace available to execute our script. So, how do we get a runspace to execute a handler? Well, we ensure that we are in a running pipeline before processing events. This is achieved by disconnecting the process: we separate the occurance of events from the act of handling them.  How does this work in practice? Let's play with &lt;span class="codeInline"&gt;System.IO.FileSystemWatcher&lt;/span&gt; :&lt;br /&gt;&lt;h2&gt;
Example with FileSystemWatcher
&lt;/h2&gt; &lt;br /&gt;This example uses the Cmdlets directly to demonstrate how the Snap-In works; you may find it easier and more familiar to work with the simple wrapper functions supplied on the Releases page. See the bottom of this page to read about these functions, called &lt;span class="codeInline"&gt;Add-EventHandler&lt;/span&gt;, &lt;span class="codeInline"&gt;Remove-EventHandler&lt;/span&gt; and &lt;span class="codeInline"&gt;Do-Events&lt;/span&gt; respectively.&lt;br /&gt;&lt;h3&gt;
Step 1
&lt;/h3&gt;&lt;pre&gt;
1# Add-PSSnapin pseventing
 
2# $fsw = new-object system.io.filesystemwatcher
3# $fsw.Path = &amp;quot;c:\temp&amp;quot;
4# $fsw.EnableRaisingEvents = $true
&lt;/pre&gt;This loads our snap-in, creates a &lt;span class="codeInline"&gt;FileSystemWatcher&lt;/span&gt; instance assigned to the variable named &lt;span class="codeInline"&gt;fsw&lt;/span&gt; and tells it to keep an eye on our temp directory. So, what events can we watch? Well, before you go running to MSDN...&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 2
&lt;/h3&gt;&lt;pre&gt;
#5 Get-EventBinding fsw -IncludeUnboundEvents | Format-Table -Auto
 
VariableName EventName TypeName          Listening
------------ --------- --------          ---------
fsw          Changed   FileSystemWatcher     False
fsw          Created   FileSystemWatcher     False
fsw          Deleted   FileSystemWatcher     False
fsw          Disposed  FileSystemWatcher     False
fsw          Error     FileSystemWatcher     False
fsw          Renamed   FileSystemWatcher     False
&lt;/pre&gt;This command lets us examine what events this variable exposes. Note that I say &lt;i&gt;variable&lt;/i&gt;, and &lt;b&gt;not&lt;/b&gt; object. This is a running theme throughout this library - &lt;b&gt;all PSEventing Cmdlets only deal with PSVariable objects, or variable names&lt;/b&gt; so do not prefix your variable names with the $ symbol. This will end up passing the instance instead of the variable, which is not what we want. This is to keep the paradigm similar to other late-bound scripting languages, like vbscript; allowing direct object references would not have been very admin-friendly. Ok, so next, lets watch the &lt;span class="codeInline"&gt;Changed&lt;/span&gt; and &lt;span class="codeInline"&gt;Deleted&lt;/span&gt; events. Btw,  Event names are not case sensitive, unless you provide the &lt;span class="codeInline"&gt;-CaseSensitive&lt;/span&gt; SwitchParameter.&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 3
&lt;/h3&gt;&lt;pre&gt;
5# Connect-Event fsw changed,deleted
&lt;/pre&gt;From this moment on, every time something is changed or deleted in c:\temp, a &lt;span class="codeInline"&gt;PSEvent&lt;/span&gt; object is added to our background event queue, even if you're busy running some other script or doing an unrelated task! Lets perform some related activity:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 4
&lt;/h3&gt;&lt;pre&gt;
6# &amp;quot;foo&amp;quot; &amp;gt; c:\temp\bar.txt
7# remove-item c:\temp\bar.txt
&lt;/pre&gt;Now, we've just created and deleted a file. You could have also gone out to explorer and created and deleted the file; all events are captured, not just those triggered from within powershell. How do we find out whap's happened, and act on this info? with the &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; cmdlet:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 5
&lt;/h3&gt;&lt;pre&gt;
8# $events = Read-Event
9# $events | Format-Table -Auto
 
Occurred            Source                                  Name    Args
--------            ------                                  ----    ----
5/9/2007 3:31:39 PM System.Management.Automation.PSVariable Changed System.IO.FileSystemEventArgs
5/9/2007 3:31:42 PM System.Management.Automation.PSVariable Deleted System.IO.FileSystemEventArgs
&lt;/pre&gt;Two events occured since we wired up the listener (or since we last called &lt;span class="codeInline"&gt;read-Event&lt;/span&gt; since each call drains the queue). Lets have a look at the EventArgs for the first one:&lt;br /&gt; &lt;br /&gt;&lt;h3&gt;
Step 6
&lt;/h3&gt;&lt;pre&gt;
10# $events[0].Args | format-table -Auto
 
ChangeType FullPath        Name
---------- --------        ----
   Changed c:\temp\bar.txt bar.txt
&lt;/pre&gt;And there you have it! &lt;br /&gt; &lt;br /&gt;Download the 1.1 release and have a look at the &lt;span class="codeInline"&gt;sqlbackup.ps1&lt;/span&gt; example script for more advanced uses.&lt;br /&gt; &lt;br /&gt;&lt;h2&gt;
Included Cmdlets
&lt;/h2&gt; &lt;br /&gt;All cmdlets have -? help support, and you can also get more information via &lt;span class="codeInline"&gt;get-help about_pseventing&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Connect-Event&lt;/b&gt; : Start tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Connect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Disconnect-Event&lt;/b&gt; : Stop tracking one or more event(s) for one or more variable(s)&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-VariableName] &amp;lt;String&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Disconnect-Event [-Variable] &amp;lt;PSVariable&amp;gt; [-EventName] &amp;lt;String[]&amp;gt; [-CaseSensitive [&amp;lt;SwitchParameter&amp;gt;]] &amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Get-EventBinding&lt;/b&gt; : Retrieve event binding information for variables&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-Variable] [&amp;lt;PSVariable[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="codeInline"&gt;Get-EventBinding [[-VariableName] [&amp;lt;String[]&amp;gt;]] [-IncludeUnboundEvents [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;i&gt;Hint : bind  or unbind all events at once for a variable&lt;/i&gt;&lt;br /&gt;&lt;pre&gt;
  1# $fsw = New-Object System.IO.FileSystemWatcher
  2# Get-EventBinding fsw -IncludeUnboundEvents | Connect-Event
&lt;/pre&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;New-Event&lt;/b&gt; : Create a custom event for insertion into the queue with an optional object payload&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;New-Event [-EventName] &amp;lt;String&amp;gt; [[-Data] [&amp;lt;PSObject&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Read-Event&lt;/b&gt; : Retrieve one or more PSEvent objects representing tracked .NET events that have been raised since the last invocation of this command.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Read-Event [-Wait [&amp;lt;SwitchParameter&amp;gt;]] [-QueueName &amp;lt;identifier&amp;gt;] [-NoFlush &amp;lt;SwitchParameter&amp;gt;] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Start-KeyHandler&lt;/b&gt; : Start generating PSEvent objects for break (cltr+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Start-KeyHandler [-CaptureCtrlC [&amp;lt;SwitchParameter&amp;gt;]] [-CaptureKeys [&amp;lt;SwitchParameter&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Stop-KeyHandler&lt;/b&gt; : Stop generating PSEvent objects for break (ctrl+c) and/or keydown events.&lt;/li&gt;&lt;ul&gt;
&lt;li&gt;&lt;span class="codeInline"&gt;Stop-KeyHandler [&amp;lt;CommonParameters&amp;gt;]&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt; &lt;br /&gt;Read some more &lt;a href="http://www.codeplex.com/PSEventing/Wiki/View.aspx?title=Syntax%20Hints&amp;amp;referringTitle=Home"&gt;Syntax Hints&lt;/a&gt; for a quick start.&lt;br /&gt; &lt;br /&gt;- Oisin Grehan / x0n&lt;br /&gt;
&lt;/div&gt;</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:54:27 GMT</pubDate><guid isPermaLink="false">UPDATED WIKI: Home 20080604055427P</guid></item><item><title>UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008)</title><link>http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919</link><description> _New Features_&lt;br /&gt;&lt;br /&gt;&amp;#42; Multiple named queue support and default queue with -QueueName parameter&lt;br /&gt;&amp;#42; Better COM support, window message pumping etc.&lt;br /&gt;&amp;#42; NoFlush &amp;#47; Peek parameter support for queue reading&lt;br /&gt;&amp;#42; Get-EventQueue command added for viewing queues and their message counts.&lt;br /&gt;&lt;br /&gt;_Changes_&lt;br /&gt;&lt;br /&gt;&amp;#42; Get-Event -&amp;#62; Read-Event&lt;br /&gt;&amp;#42; Connect-EventListener -&amp;#62; Connect-Event&lt;br /&gt;&amp;#42; Disconnect-EventListener -&amp;#62; Disconnect-Event&lt;br /&gt;</description><author></author><pubDate>Wed, 04 Jun 2008 17:41:07 GMT</pubDate><guid isPermaLink="false">UPDATED RELEASE: PSEventing 1.1 (Jun 04, 2008) 20080604054107P</guid></item><item><title>CLOSED ISSUE: sometimes get-event (now read-event) -wait returns immediately with no events</title><link>http://www.codeplex.com/PSEventing/WorkItem/View.aspx?WorkItemId=4856</link><description>sometimes read-event -wait returns immediately with no events - seems to be related to using ctrl&amp;#43;c to break out&amp;#59; a subsequent call immediately returns, but additional calls behave as normal. Probably not resetting my exit flag. doh.&lt;br /&gt;</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:34:37 GMT</pubDate><guid isPermaLink="false">CLOSED ISSUE: sometimes get-event (now read-event) -wait returns immediately with no events 20080604053437P</guid></item><item><title>CLOSED FEATURE: add -noflush to read-event (previously get-event) cmdlet</title><link>http://www.codeplex.com/PSEventing/WorkItem/View.aspx?WorkItemId=4677</link><description>currently a read flushes the queue&amp;#59; this would allow a &amp;#34;peek&amp;#34; of the default queue &amp;#40;or specific named queue&amp;#41; without emptying it.&lt;br /&gt;</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:34:36 GMT</pubDate><guid isPermaLink="false">CLOSED FEATURE: add -noflush to read-event (previously get-event) cmdlet 20080604053436P</guid></item><item><title>Source code checked in</title><link>http://www.codeplex.com/PSEventing/SourceControl/ListDownloadableCommits.aspx</link><description></description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:34:35 GMT</pubDate><guid isPermaLink="false">Source code checked in 20080604053435P</guid></item><item><title>COMMENTED ISSUE: sometimes get-event (now read-event) -wait returns immediately with no events</title><link>http://www.codeplex.com/PSEventing/WorkItem/View.aspx?WorkItemId=4856</link><description>sometimes read-event -wait returns immediately with no events - seems to be related to using ctrl&amp;#43;c to break out&amp;#59; a subsequent call immediately returns, but additional calls behave as normal. Probably not resetting my exit flag. doh.&lt;br /&gt;Comments: ** Comment from web user: oisin ** &lt;p&gt;conditions for repro&amp;#58;&lt;/p&gt;&lt;p&gt;ps&amp;#62; start-keyhandler -capturectrl&lt;br /&gt;ps&amp;#62; read-event -wait&lt;br /&gt;... hit ctrlc - returns ctrlc event ...&lt;br /&gt;ps&amp;#62; read-event -wait&lt;br /&gt;&amp;#40;returns immediately with no event&amp;#33;&amp;#41;&lt;br /&gt;ps&amp;#62; read-event -wait&lt;br /&gt;&amp;#40;waits correctly&amp;#41;&lt;br /&gt;&lt;/p&gt;</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:33:18 GMT</pubDate><guid isPermaLink="false">COMMENTED ISSUE: sometimes get-event (now read-event) -wait returns immediately with no events 20080604053318P</guid></item><item><title>CLOSED ISSUE: Unable to bind to EventHandler&lt;T&gt; events</title><link>http://www.codeplex.com/PSEventing/WorkItem/View.aspx?WorkItemId=4323</link><description>The snapin cannot handle events with EventHandler&amp;#60;T&amp;#62; generic delegates.&lt;br /&gt;Comments: fixed in 1.1</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:07:05 GMT</pubDate><guid isPermaLink="false">CLOSED ISSUE: Unable to bind to EventHandler&lt;T&gt; events 20080604050705P</guid></item><item><title>UPDATED RELEASE: PSEventing 1.1</title><link>http://www.codeplex.com/PSEventing/Release/ProjectReleases.aspx?ReleaseId=5919</link><description> _New Features_&lt;br /&gt;&lt;br /&gt;&amp;#42; Multiple named queue support &amp;#43; default queue &lt;br /&gt;&amp;#42; Better COM support&lt;br /&gt;&amp;#42; NoFlush &amp;#47; Peek support for queue reading&lt;br /&gt;&amp;#42; Get-EventQueue command added&lt;br /&gt;&lt;br /&gt;_Changes_&lt;br /&gt;&lt;br /&gt;&amp;#42; Get-Event -&amp;#62; Read-Event&lt;br /&gt;&amp;#42; Connect-EventListener -&amp;#62; Connect-Event&lt;br /&gt;&amp;#42; Disconnect-EventListener -&amp;#62; Disconnect-Event&lt;br /&gt;</description><author></author><pubDate>Wed, 04 Jun 2008 17:05:57 GMT</pubDate><guid isPermaLink="false">UPDATED RELEASE: PSEventing 1.1 20080604050557P</guid></item><item><title>Source code checked in</title><link>http://www.codeplex.com/PSEventing/SourceControl/ListDownloadableCommits.aspx</link><description>1.1 Release&amp;#59; added WiX 3.0 installer project.</description><author>oisin</author><pubDate>Wed, 04 Jun 2008 17:01:15 GMT</pubDate><guid isPermaLink="false">Source code checked in 20080604050115P</guid></item></channel></rss>