【问题标题】:Citrix 7.6 Broker SDK C#/PowershellCitrix 7.6 代理 SDK C#/Powershell
【发布时间】:2015-05-07 11:27:11
【问题描述】:

有人使用过 Citrix 7.6 BrokerSession SDK 吗?例如,我不知道如何执行这样的命令:

GetBrokerSessionCommand getCmd = new GetBrokerSessionCommand();
getCmd.AdminAddress = "citrixServer:80";
var result = getCmd.Invoke();

这给了我一条错误消息:“不能直接调用从 PSCmdlet 派生的 Cmdlet。

在早期的 6.5 SDK 中,我可以这样做:

string[] servers = new string[] { };
GetXAWorkerGroupByName workerGroup = new GetXAWorkerGroupByName();
workerGroup.WorkerGroupName = new string[] { workerGroupName };
workerGroup.ComputerName = XenAppController;
foreach (XAWorkerGroup _workerGroup in CitrixRunspaceFactory.DefaultRunspace.ExecuteCommand(workerGroup))
                {
                    servers = _workerGroup.ServerNames;
                }

            return servers;

但是现在 CitrixRunspaceFactory 不再存在了? 出于以更简单的方式处理异常的简单原因,我想避免使用 Powershell 类和 Powershell.Create() 执行命令。

【问题讨论】:

  • 如果有人对 7.6 中的 SDK 有所了解,我会很高兴的。

标签: c# powershell citrix xenapp


【解决方案1】:

Citrix 7.6 cmdlet 不是从 Cmdlet 类而是从 PSCmdlet 派生的。因此它们更多地绑定到 PowerShell 引擎,并且必须在其中调用:

    Runspace runSpace = RunspaceFactory.CreateRunspace();
    runSpace.Open();
    PSSnapInException psex;
    runSpace.RunspaceConfiguration.AddPSSnapIn("Citrix.Broker.Admin.V2", out psex);
    Pipeline pipeline = runSpace.CreatePipeline();

    Command getSession = new Command("Get-BrokerSession");
    getSession.Parameters.Add("AdminAddress", "SERVERNAME");
    pipeline.Commands.Add(getSession);

    Collection<PSObject> output = pipeline.Invoke();

Citrix SDK 中强类型类的 AFAIK 好时光已经一去不复返了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-01
    • 1970-01-01
    • 2011-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多