Sunday, January 28, 2007

Windows PowerShell : Working With WMI Events

 Jeffrey Snover has blogged another good PowerShell function (link below) which has gotten me to thinking about PoSH and CmdLets from a slightly different direction.

Jeffrey's function shows how easy it is to extend PowerShell without building CmdLets.  This function parks an event watcher on a WMI event class and returns objects to the pipeline or command line.

The great difference between functions and CmdLets is that CmdLets give you very powerful control over the behavior of the CmdLet through the use of switches,  CmdLets can also help us dig deeper into the NET classes and quickly expose information at a higher and more convenient level.

If a function gives you all you need for your work then I suggest the function is the best approach.  When the function becomes to complex or cannot readily grab the information needed or if you need much better error control then is when a CmdLet can come to the rescue.

Check out Jeff's nifty "Event Watcher".

Link to Windows PowerShell : Working With WMI Events

No comments:

Post a Comment