开发者

How do I get the current Cmdlet from another object?

开发者 https://www.devze.com 2022-12-31 22:02 出处:网络
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

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

精彩评论

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