【问题标题】:Powershell - Get Variable from C# CmdletPowershell - 从 C# Cmdlet 获取变量
【发布时间】:2010-12-15 07:00:14
【问题描述】:

我正在编写一个需要获取全局脚本变量值的 C# Cmdlet。 我该怎么做?

我注意到 Runspace 有 SessionStateProxy.GetVariable 方法。 我可以从 C# Cmdlet 访问运行空间吗?

谢谢!

【问题讨论】:

    标签: c# powershell cmdlets


    【解决方案1】:

    如果您要实现 PSCmdlet,请使用 this 变量来访问它,如下所示:

    this.SessionState.PSVariable.GetValue()
    

    【讨论】:

    • 或更短:this.GetVariableValue(...)
    • 有System.Management.Automation.Cmdlet的选项吗?
    猜你喜欢
    • 2013-06-08
    • 1970-01-01
    • 2018-12-20
    • 2017-11-01
    • 1970-01-01
    • 2018-01-09
    • 2015-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多