我需要从创建的 powershell 主机捕获 PowerShell 函数调用并覆盖它。怎么可能?
InitialSessionState iss = InitialSessionState.CreateDefault();
iss.LanguageMode = PSLanguageMode.FullLanguage;
iss.ImportPSModule(new string[] { "TestModule.psm1" });
Runspace rs = RunspaceFactory.CreateRunspace(iss);
rs.Open();
Pipeline pl = rs.CreatePipeline();
pl.Commands.AddScript("TestFunction testParam");
var res = pl.Invoke();
rs.Close();
我的任务是动态覆盖TestFunction,女巫位于TestModule,我该怎么做?