locked
Accessing Lync via remote powershell not working? RRS feed

  • Question

  • I am trying to access the OCSPowershell virtual directory in Lync 2013 Hosting Pack. I have basically used the same commands as I did with Exchange except changed the schema. It doesn't seem to work and returns a HTTP 500 error.

    Just so you know I can access it from the same server using Powershell but just not using C# running on a ASP.NET application (the App Pool for the ASP.NET application IS running as the domain admin that is part of CSAdminsitrators)

    Is my code correct? Is the schema correct? I just can't figure out how to get it working! It works with Exchange!!

    Open fails:

    this.wsConn = GetConnection(uri, username, password, connectionType == Enumerations.ConnectionType.Kerberos ? true : false);
    
    this.domainController = domainController;
    
    // Create our runspace
    runspace = RunspaceFactory.CreateRunspace(wsConn);
    
    // Open the connection
    runspace.Open();

    The connection information:

    private WSManConnectionInfo GetConnection(string uri, string username, string password, bool kerberos)
    {
                SecureString pwd = new SecureString();
                foreach (char x in password)
                    pwd.AppendChar(x);
    
                PSCredential ps = new PSCredential(username, pwd);
    
                WSManConnectionInfo wsinfo = new WSManConnectionInfo(new Uri("https://lync.lab.local/ocspowershell"), "http://schemas.microsoft.com/powershell/Microsoft.PowerShell", ps);
                wsinfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
                wsinfo.SkipCACheck = true;
                wsinfo.SkipCNCheck = true;
                wsinfo.SkipRevocationCheck = true;
                wsinfo.OpenTimeout = 9000;
    
                return wsinfo;
            }

    I have also enabled basic authentication on the OCSPowershell virtual directory and I can browse to the directory via IE

    Monday, January 20, 2014 2:01 AM

Answers

  • I suggest re-wording your question and post on this Lync Server forum:

    Lync Server Management

    It's more likely Powershell gurus are looking at that forum. This one is devoted to application development using the Lync Server SDK.

    • Marked as answer by Quadrantids Friday, February 7, 2014 4:05 AM
    Tuesday, January 21, 2014 2:40 PM

All replies

  • Well I got it working by switching AuthenticationMechanism from Basic to Default.....

    Anyone know if you can import the Lync modules somehow using this method?

    Monday, January 20, 2014 4:01 AM
  • I suggest re-wording your question and post on this Lync Server forum:

    Lync Server Management

    It's more likely Powershell gurus are looking at that forum. This one is devoted to application development using the Lync Server SDK.

    • Marked as answer by Quadrantids Friday, February 7, 2014 4:05 AM
    Tuesday, January 21, 2014 2:40 PM