2016-06-24 3 views

답변

1

PSCmdlet.GetVariableValue(string) 방법이 사용될 수있다 :

using System.Management.Automation; 

namespace MyModule 
{ 

    [Cmdlet(VerbsDiagnostic.Test, "GetVariableValueMethod")] 
    public class TestGetVariableValueMethod : PSCmdlet 
    { 
     protected override void ProcessRecord() 
     { 
      ConfirmImpact confirmPref = 
       (ConfirmImpact)this.GetVariableValue("global:ConfirmPreference"); 
      WriteObject(confirmPref); 
     } 
    } 
} 

테스트 파워 쉘 내 : PSHost` 여러`Runspace`을 가질 수있다`동일한 반면

PS > Test-GetVariableValueMethod 
High 

PS > $ConfirmPreference = 'Low' 

PS > Test-GetVariableValueMethod 
Low