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 = "domainusername"





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:ScriptsStart-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:scriptsstart- csremotepowershell.ps1 –CSPoolFQDN CSPool01.contoso.local

o    To use an authentication prompt

§  powershell.exe -noexit -executionpolicy bypass -file c:scriptsstart- csremotepowershell.ps1 -AuthenticationPrompt -CSPoolFQDN CSpool01.contoso.local -AdminUsername contosoadministrator


Comments (9)
  1. 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]

  2. U2412M says:

    Good work… Thank you for the valuable information..

  3. U2713H says:

    Very nice post of the day. I hope every one should get the maximum benefit from this.

  4. Coffee In India says:

    Good work… Thank you for the valuable information..

Comments are closed.

Skip to main content