tags:

views:

19

answers:

1

What's the best way to get the current PowerShell Cmdlet from another object? If I create a helper object that is not a Cmdlet but will be called by Cmdlets, the helper methods may want to call WriteVerbose, WriteDebug etc. What's the best way to get access to that? Is there a static PowerShell method that will return the current Cmdlet or do I need to have the Cmdlet pass itself to the helper?

A: 

AFAICT you will need to pass your cmdlet object to the helper class so it can access those instance methods WriteVerbose, WriteDebug, etc, I'm not aware of any other public "static" access mechanism to get to these output streams.

Keith Hill