设置SPDebug-跟踪1在PowerShell主机中不工作

设置SPDebug-跟踪1在PowerShell主机中不工作,powershell,Powershell,我有几个PowerShell主机,在这些主机中设置SPDebug-trace 1不起作用 我测试了PoshConsole,在这里它可以工作,但例如PowerShell SDK中的Host6就不能工作 你知道主机需要什么才能工作吗?它以什么方式不工作?如果没有看到任何输出,是否覆盖了PSHostUserInterface基类的WriteDebugLine()方法,例如: public override void WriteDebugLine(string message) { this.W

我有几个PowerShell主机,在这些主机中设置SPDebug-trace 1不起作用

我测试了PoshConsole,在这里它可以工作,但例如PowerShell SDK中的Host6就不能工作


你知道主机需要什么才能工作吗?

它以什么方式不工作?如果没有看到任何输出,是否覆盖了PSHostUserInterface基类的WriteDebugLine()方法,例如:

public override void WriteDebugLine(string message)
{
    this.WriteLine(ConsoleColor.DarkYellow, ConsoleColor.Black,
        String.Format(CultureInfo.CurrentCulture, "DEBUG: {0}", message));
}

我的聪明同事Jan Pieter Guelen在使用Reflector通过PowerShell自动化api后找到了答案。必须使用以下代码在CreatePipeline中启用历史记录:

pipeline = runspace.CreatePipeline("", true);

现在追踪工作!即使是Wrox的《Windows PowerShell编程》一书也没有提到这一点:-(PowerShell SDK示例(Host6)也应该包括这一点……PoshConsole也有这一点,但我从未想过这会是个问题。

很有趣。不确定历史与跟踪有什么关系,但如果它有效的话。:-)