术语';连接QADService';无法识别为cmdlet的名称。。。内部C#函数

术语';连接QADService';无法识别为cmdlet的名称。。。内部C#函数,c#,powershell,active-directory,cmdlets,C#,Powershell,Active Directory,Cmdlets,请有人帮助理解为什么Csharp函数中包含以下代码 Runspace runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); Pipeline pipe = runspace.CreatePipeline(); Command connectToActDir = new Command("connect-QADService"); connectToActDir.Parameters.Ad

请有人帮助理解为什么Csharp函数中包含以下代码

    Runspace runspace = RunspaceFactory.CreateRunspace();
    runspace.Open();
    Pipeline pipe = runspace.CreatePipeline();
    Command connectToActDir = new Command("connect-QADService");
    connectToActDir.Parameters.Add("Service", "'ip:port'");
    connectToActDir.Parameters.Add("ConnectionAccount", "'user.local\administrator'");
    connectToActDir.Parameters.Add("ConnectionPassword", "'password'");
    pipe.Commands.Add(connectToActDir);
    pipe.Invoke();
导致以下错误

术语“connect QADService”不能识别为cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

当安装ActiveRoles cmdlet并在power shell中运行等效命令时,会成功。我是否在项目引用中遗漏了一些dll?
谢谢,默认情况下,Quest-ActiveRoles cmdlet不会加载到PowerShell会话中,因为它们不是PowerShell的一部分

PowerShell 3将在需要时自动加载模块。我不知道在使用运行空间时这是否成立,因为我从未以这种方式使用过PowerShell

您是否在PowerShell配置文件中加载任务管理单元或模块?您需要在C#代码中执行相同的操作