简体   繁体   English

在与Lync的远程会话中执行标准PowerShell cmdlet

[英]Executing standard PowerShell cmdlets in remote session to Lync

Having an odd issue over here. 这里有一个奇怪的问题。 I'm able to start a remote session from my C# application to PowerShell in a Lync Server 2010 instance. 我可以启动从C#应用程序到Lync Server 2010实例中的PowerShell的远程会话。 I'm able to get all the Lync-specific cmdlets and execute them, but if I try to do something with a standard cmdlet — in my case "get-content" in order to convert a file to a byte array — it will not recognize the command. 我可以获取所有Lync特定的cmdlet并执行它们,但是如果我尝试使用标准cmdlet进行操作(在我的情况下为“ get-content”,以便将文件转换为字节数组),则不会识别命令。

Is there a way/need to load the standard PS set of cmdlets into that session? 是否有办法将标准PS cmdlet集加载到该会话中? It feels like I'm missing something here... 感觉我在这里想念什么...

Thanks in advance! 提前致谢!

N ñ

EDIT: Here's a code snippet of what I have going on... 编辑:这是我正在进行的代码片段...

PSCredential creds = new PSCredential(lyncUser, lyncPW);

        WSManConnectionInfo conn = new WSManConnectionInfo(new Uri(lyncURI), schema, creds);

        conn.AuthenticationMechanism = AuthenticationMechanism.Default;

        Runspace rs = RunspaceFactory.CreateRunspace(conn);
        rs.Open();


        List<FileInfo> files = getWavFiles();

        foreach (var file in files)
        {

            Pipeline lyncCommands = rs.CreatePipeline();

            Command getContent = new Command("Get-Content");
            getContent.Parameters.Add(file.FullName);
            getContent.Parameters.Add("readcount", 0);
            getContent.Parameters.Add("encoding", "byte");
            lyncCommands.Commands.Add(getContent);

            Command importAnnouncement = new Command("import-csannouncementfile");
            importAnnouncement.Parameters.Add("parent", "applicationserver:myserver.mydomain.mycom");
            importAnnouncement.Parameters.Add("filename", file.Name);
            importAnnouncement.Parameters.Add("force");

            lyncCommands.Commands.Add(importAnnouncement);

            foreach (PSObject r in lyncCommands.Invoke())
            {
                Console.WriteLine(r.ToString() + Environment.NewLine);
            }
        }

The "import-csannouncement" part will work just fine... it's "get-content" part that gets dicey... “ import-csannouncement”部分将正常工作...它的“ get-content”部分非常有用...

You can try re-configuring the LYNC server remote sessions for Full Language mode. 您可以尝试将LYNC服务器远程会话重新配置为“全语言”模式。

(Link is about configuring for Exchange servers, but I believe it's the same issue) (链接是关于为Exchange服务器配置的,但我相信这是相同的问题)

http://blog.mimecast.com/2011/08/get-full-control-over-your-exchange-remote-powershell-session/ http://blog.mimecast.com/2011/08/get-full-control-over-your-exchange-remote-powershell-session/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在C#中执行Powershell Cmdlet代码 - Executing Powershell Cmdlets Code in C# 如果我使用 enter/import-pssession cmdlet,为什么在远程计算机(使用参数)上以编程方式 (C#) 执行 powershell cmdlet 不起作用? - Why executing powershell cmdlets programmatically (C#) on remote machine (using arguments) doesn't work if I use enter/import-pssession cmdlets? Powershell远程无标准输出 - Powershell remote no standard output 使用PowerShell CmdLets进行交互 - Interoping With PowerShell CmdLets 从网页执行远程Powershell命令 - Executing remote Powershell commands from a Web page 运行Powershell cmdlet会引发异常 - Running powershell cmdlets throws Exceptions 在 C# 中运行 PowerShell cmdlet - Running PowerShell cmdlets in C# 如何获取包含反序列化对象列表的Cmdlet结果的属性(多值属性)(从C#执行Powershell cmdlet) - How to get the properties of Cmdlet results which contain list of deserialized objects (multi-valued properties)(executing powershell cmdlets from c#) Powershell通用会话并在Exchange远程管理会话中导入此会话 - Powershell generic session and import this session in Exchange remote management session 在C#中检查远程PowerShell会话状态 - Check remote PowerShell session status in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM