Connect to Microsoft Lync Server 2010 Remote PowerShell from the Desktop

By Nick Smith, Microsoft


Before running this script, ensure that the client meets all the requirements for a remote connection to Windows PowerShell. Here are the requirements:


·         Windows PowerShell v2.0

·         .NET Framework 2.0 Service Pack 1

·         Windows Remote Management (WinRM) 2.0


The requirements are included in the Windows Management Framework, available for download. (For a detailed description of system requirements for Windows PowerShell 2.0, check out this support article:


To create a desktop shortcut to start a Windows PowerShell remote session connected to Microsoft Lync Server 2010, follow these instructions:


1.    Open Notepad (or your favorite text or script editor).

2.    Copy the following script and paste it into Notepad.




#* Author: Nick Smith (

#* Date: 6/20/2010

#* Purpose: This is a script that can be used when creating desktop icons that

#*    will allow the user an easy way of connecting to remote powershell into a

#*    Lync Server environment.




Param (

    [switch] $AuthenticationPrompt = $false,

    [string] $CSPoolFQDN = (read-host "Enter the FQDN of the Lync Server Pool"),

    [string] $AdminUsername = "domain\username"





If ($AuthenticationPrompt) {

    Write-Host -ForegroundColor Green "Requesting Credentials for Lync Server Administrative Session"

    $CSSession = New-PSSession -ConnectionUri https://$CSPoolFQDN/ocspowershell -Credential $AdminUsername -ErrorAction SilentlyContinue


else {

    $CSSession = New-PSSession -ConnectionUri https://$CSPoolFQDN/ocspowershell -Authentication NegotiateWithImplicitCredential -ErrorAction SilentlyContinue




If ($Error.count -gt 0){

    Write-Host -ForegroundColor Red "Unable to Connect to Lync Server Administrative Session`n Error:" $Error


else {

    $ImportResults = Import-PSSession -Session $CSSession

    Write-Host -ForegroundColor Green "Connected to Lync Server Administrative Session`nImported" $ImportResults.ExportedFunctions.count "CS Functions"



cd $env:UserProfile



3.    Save the file with a .ps1 extension, for example, C:\Scripts\Start-CsRemotePowerShell.ps1


4.    Create an shortcut on the client desktop with the following target. Be sure the change the highlighted values to match your environment.


o    To use integrated authentication

§  powershell.exe -noexit -executionpolicy bypass -file c:\scripts\start- csremotepowershell.ps1 –CSPoolFQDN CSPool01.contoso.local

o    To use an authentication prompt

§  powershell.exe -noexit -executionpolicy bypass -file c:\scripts\start- csremotepowershell.ps1 -AuthenticationPrompt -CSPoolFQDN CSpool01.contoso.local -AdminUsername contoso\administrator


Comments (6)

  1. CSPShell says:

    Hey, Benoît. Can you tell us when that error message pops up (that is, which line in the script)? We've never seen that particular error message before but, then again, we haven't done a TON of stuff with remote PowerShell, either. Two things you might try: 1) On the remote computer, run the enable-PsRemoting cmdlet (you'll need to be running PowerShell as an admin in order to do that); and, 2) on the remote computer, add the name of your workstation to Internet Explorer'sTrusted Sites (Tools/Internet Options/Security). No guarantee that either of those things will help, but they won't hurt, and they often clear up problems that people encounter with remote PowerShell.

  2. CSPShell says:

    Thanks for pointing this out. .NET Framework 2.0 SP1 is actually a requirement for any installation of Windows PowerShell 2.0. We've updated the article with this info, plus added a link that will take you to a more detailed list of requirements for PowerShell 2.0

  3. alex says:

    Hi this is useful thanks.

  4. Benoît says:


    For a windows XP SP3 Desktop, it requires also .NET Framework 2.0 SP1

  5. Benoît says:

    What a prompt answer !

    I'm currently testing your script and experiencing a strange error with the 2 authentication ways :

    " The SSL certificate could not be checked for revocation. The server used to chec

    k for revocation might be unreachable. For more information, see the about_Remot

    e_Troubleshooting Help topic. "

    Have you ever heard about this ??

    Thanks a lot for any answer :o)

  6. EdYoung [MSFT] says:

    Whenever you connect to an HTTPS URL, such as is used for remote PowerShell, the server needs to have a certificate 'proving' it matches the URL you entered, to prevent someone spoofing the website. To make sure the cert is valid, the client program needs to check with the certificate authority (CA) which issued the certificate to see if it's been revoked. This error indicates that it wasn't able to do so. This can happen if (for example) you used an internal CA within your company firewall to issue a cert, then try to connect from outside the firewall, though there are other posibilities.

    You may be able to diagnose what's up with the certificate checking based on the above; alternatively,

    you can work around the problem at the risk of lowering security if you run

    $so = new-pssessionoptions -skiprevocationcheck

    then pass -SessionOptions $so as an extra argument to the New-PsSession command you're using to connect.

    [By the way, it is not necessary to run Enable-PSRemoting to use Lync's remote powershell implementation, because we don't use the default remoting endpoint anyway]

Skip to main content