开发者

How do I get the current Cmdlet from another object?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜