如何使用 BeginSignIn 或如何登录 Skype for Business 使用 PowerShell 进行自动 phone 呼叫

How to use BeginSignIn or how to login to Skype for Business for making automatic phone call using PowerShell

我找到了 THIS link,其中展示了如何使用 C# 登录 Skype/Lynk。我还在 C:\Program Files (x86)\Microsoft Office 2013\LyncSDK\samples\AudioVideoConversation\AudioVideoConversation.sln 下找到了示例 Visual Studio 解决方案,您将在安装 Lynk 2013 时获得开发工具包。在 Visual Studio 中成功构建此项目后,您可以从 Skype for Business 拨打 phone 电话。

我正在开发一个 PowerShell 脚本,通过将此 .Net 项目中的代码转换为 PowerShell 来进行自动 phone 调用,但是,不确定如何将其成功转换为 PowerShell。我卡在了第一步,通过 PowerShell 代码登录 Lynk。

Add-Type -Path "C:\Program Files (x86)\Microsoft Office 2013\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.dll"

$LC = [Microsoft.Lync.Model.LyncClient]::GetClient()

$obj = [System.Object]::new()
$iP = [System.IntPtr]::new(1)
$acb = [System.AsyncCallback]::new($obj,$iP)

$LC.BeginSignIn("testuser@contoso.com","contoso\sshahoo",'P@ssw0rd', $acb, $obj)

有人可以分享如何使用 PowerShell 连接到 Skype for Business 并拨打 Phone 电话吗?

经过一些研究和编码,我现在能够通过按钮单击事件登录到 Skype for Business 并开始 phone 通话。如果有人感兴趣,下面是代码:

    private void btnCall_Click(object sender, EventArgs e)
    {
        //if this client is in UISuppressionMode...
        if (client.InSuppressedMode && client.State == ClientState.Uninitialized)
        {
            //...need to initialize it
            try
            {
                client.BeginInitialize(this.ClientInitialized, null);
            }
            catch (LyncClientException lyncClientException)
            {
                Console.WriteLine(lyncClientException);
            }
            catch (SystemException systemException)
            {
                if (LyncModelExceptionHelper.IsLyncException(systemException))
                {
                    // Log the exception thrown by the Lync Model API.
                    Console.WriteLine("Error: " + systemException);
                }
                else
                {
                    // Rethrow the SystemException which did not come from the Lync Model API.
                    throw;
                }
            }
        }
        else //not in UI Suppression, so the client was already initialized
        {
            //registers for conversation related events
            //these events will occur when new conversations are created (incoming/outgoing) and removed
            //client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
            //client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;

            //sign-in or contact selection
            SignInToLync();
        }
        SendLyncCall("+6512345678", "Hello, I am calling regarding an open ticket");
    }

    LyncClient client = LyncClient.GetClient();
    private void SignInToLync()
    {
        try
        {
            client.BeginSignIn("abc@contoso.com", "abc@contoso.com", "Pass@1234", HandleEndSignIn, null);
        }
        catch (LyncClientException lyncClientException)
        {
            Console.WriteLine(lyncClientException);
        }
        catch (SystemException systemException)
        {
            if (LyncModelExceptionHelper.IsLyncException(systemException))
            {
                // Log the exception thrown by the Lync Model API.
                Console.WriteLine("Error: " + systemException); 
            }
            else
            {
                // Rethrow the SystemException which did not come from the Lync Model API.
                throw;
            }
        }
    }