c# - "Cannot Invoke this function because the current host does not implement it"

标签 c# powershell

在这里使用程序:http://www.codeproject.com/Articles/18409/Asynchronously-Execute-PowerShell-Scripts-from-C

我遇到错误:脚本错误:System.Management.Automation.CmdletInvocationException:无法调用此函数,因为当前主机未实现它。 ---> System.Management.Automation.Host.HostException: 无法调用此函数,因为当前主机未实现它。

当使用我在我们其中一台服务器的本地 bin 中的脚本时,例如只需输入:

get-serverlist“属性组”ServerRange | CollectPerfData.ps1*

最佳答案

如果您执行需要与主机进程交互的脚本,例如Write-Host, Read-Host 然后你必须实现主机接口(interface)。拿个look at this script有关如何执行此操作的示例。

关于c# - "Cannot Invoke this function because the current host does not implement it",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19414514/

相关文章:

windows - 在 Windows 上更改语言和区域设置

animation - PowerShell:控制台和 SetCursorPosition 中的角色动画变得疯狂

powershell - 检查处理器体系结构并继续执行if语句

c# - 如何在 STA 线程中运行某些东西?

c# - IObjectSet 包含 CompiledQuery 的扩展方法错误

c# - 使用 C# Task Schedule 库启用/禁用任务

regex - 用于在引号之间提取名称的正则表达式 (Regex) - Powershell

c# - 如何为在套接字上发送的文件创建长度前缀?

c# - 包装托管代码以供非托管使用

powershell - PowerShell 中的特殊字符