1
$ConfirmPreference
과 같은 전역 변수 값을 C#으로 작성된 이진 Powershell 모듈 내에서 Powershell 호스트로부터 어떻게 가져 옵니까?바이너리 Powershell 모듈 - Powershell 호스트에서 전역 변수 값 가져 오기
$ConfirmPreference
과 같은 전역 변수 값을 C#으로 작성된 이진 Powershell 모듈 내에서 Powershell 호스트로부터 어떻게 가져 옵니까?바이너리 Powershell 모듈 - Powershell 호스트에서 전역 변수 값 가져 오기
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
전역 변수, Runspace' '에 특이 에스. – PetSerAl