0
我正在C#中實現一個自定義參數完成器,從IArgumentCompleter繼承。在CompleteArgument
,我嘗試做的如何在IArgumentCompleter的C#實現中獲取當前文件系統的位置?
$ExecutionContext.SessionState.Path.CurrentFileSystemLocation.ProviderPath
相當於我試圖
Runspace.DefaultRunspace.SessionStateProxy.Path.CurrentFileSystemLocation.Path
而是拋出異常告訴我管道已經運行。
這樣做的正確方法是什麼?
'EngineIntrinsics EI;使用(PowerShell ps = PowerShell.Create(RunspaceMode.CurrentRunspace)){ei = ps.AddScript(「$ ExecutionContext」)。調用()[0]}' –
PetSerAl