What's the best way to get the current PowerShell Cmdlet from another object? If I create a helper object that is not a Cm开发者_如何学Godlet 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?
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.
精彩评论