While articles on this blog are primarily focused on real time communication capabilities provided throughout Lync on-premises environments, as Microsoft moves forward with including more voice and video features in their cloud offering then integration and management of Lync Online will start become more common here.

Background

One of the first steps in this journey is understanding how a Lync Online tenant can administer their environment.  Just as with a Lync on-premises deployment there are two primary tools for doing this: a web-based graphical user interface (GUI) and a command-line shell.

Since the original Lync 2010 release the GUI tool has been a Microsoft Silverlight based control panel that was also delivered as a web portal provided by IIS running on a Lync Front End server.  The shell portion has leveraged Windows PowerShell by using a module of several hundred cmdlets to control every aspect of the platform.

image

Yet Lync Online, soon to be upgraded to Skype for Business Online, leverages a single, massive multitenant deployment of Lync 2013 thus a large portion of server-side capabilities are not exposed to the individual tenant administrators.  Clearly disastrous results could occur if a single tenant had the ability to modify the behavior of any single component or parameter that could potentially impact any or all other tenants. Because of this shared model the administration tools for managing Lync Online are quite different than what administrators of on-premises deployments are used to.

First off the Lync Control Panel is replaced with the Lync Admin Center which is a component of the centralized Office 365 Admin Center.  As seen below the listed sections in the admin center is a mere shadow of what is available in the control panel shown above.

image

As expected the available PowerShell cmdlets is also quite different between the platforms.  With just a couple commands the current total of individual cmdlets in the Lync on-premises server module can be retrieved.

image

As of the time this article was written there are only 50 unique cmdlets available in Lync Online, which is quite the difference from the nearly 750 cmdlets provided to manage an on-premises deployment of Lync.

Installation

While connecting to the admin center is as simple as opening a web browser on any computer or device with Internet access leveraging PowerShell does require a short one-time setup for a Windows workstation.

As a prerequisite the Windows operating system on the computer to be used must be of the 64-bit variety and be running at a minimum Windows 7 or Windows Server 2008 R2.  Additionally Windows PowerShell 3.0 or newer must be installed on the system.  Windows 7 and Server 2008 R2 with at least Service Pack 1 will already fulfill this requirement as PowerShell 3.0 is the default version, with newer operating systems (e.g. Windows 8 and Server 2012) utilizing 4.0 and newer.

  • To confirm the version of PowerShell running on the selected Windows computer open a new PowerShell session and execute the $PSVersionTable cmdlet and then take note of the PSVersion value.

PS C:\Windows\system32> $PSversionTable

Name                           Value
—-                           —–
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.3.9600.17090
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

image

Once completed the installation will not create any shortcuts to a separate shell or application, but the Lync Online Connector module will be installed and ready to be imported into PowerShell.

As this new command module is not part of the inherent Windows installation and although provided and signed by Microsoft it was downloaded from the Internet, thus the default behavior of PowerShell will be to block even the computer administrator from importing the command module.  To resolve this the script execution policy must be modified.

  • Open a Windows PowerShell session as an administrator and then enter the following cmdlet to query the existing script execution policy configuration.

PS C:\> Get-ExecutionPolicy
Restricted

If this workstation has already been configured to use another product’s external modules then the value may already be set to something other than Restricted.  If that is the case then the next step can possibly be skipped, depending on the current value.

If the default value of Restricted is set then this will need to be changed in order to import the Lync command module each time a new PowerShell instance is started.

  • In the same PowerShell window enter the following Set-ExecutionPolicy cmdlet to lower the policy to a compatible level of RemoteSigned required to use the Lync Online module.

PS C:\> Set-ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

This completes the one-time setup for the workstation and these steps should not need to be performed again.

Connecting to Lync Online

While there are already a handful of articles on this topic, including the official TechNet documentation, many of these include extraneous steps which make it a bit difficult for the first time user to understand the process.  This section will cover the minimum number of basic commands required to connected, while a later section will introduce a customized script which can be used to automate these individual steps for repeated future use.

What is important to understand is that the installed command module does not contain a complete set of Lync Online cmdlets, but is instead a single cmdlet that is used to establish a remote PowerShell session to Lync Online.  Each online user account which is configured as an administrator in Lync is allowed up to 3 simultaneously remote PowerShell sessions.

The individual steps listed here all include the optional -Verbose parameter in the screenshots for instructional purposes and can be omitted when running each cmdlet.

  • Open a Windows PowerShell session and then enter the Import-Module cmdlet to import the Lync Online command module into the active PowerShell instance.

Import-Module LyncOnlineConnector

image

If the Import-Module command fails with a message about not being able locate the modules then a reboot may be necessary to complete the previous installation.

  • Enter the following  command to establish a connection to Lync Online which automatically triggers a prompt for the user credentials of a Lync Online administrator account.

$session = New-CsOnlineSession

image

image

  • Enter the following command to complete the connection by importing the Lync Online cmdlets form the remote session into the local session.

Import-PSSession $session

image

These three easy steps have now provided remote PowerShell access to the connected Lync Online tenant.  To test connectivity simply try running one of the supported Lync Online cmdlets, like Get-CsClientPolicy.

Managing Lync Online

As previously mentioned there are only a handful of cmdlets for Lync Online so a majority of the common Lync cmdlets will not work here.  How is one to know exactly which cmdlets are available to the Lync Online administrator?  One option is to look at the TechNet documentation listing the Lync Online cmdlets but as that information is not always up to date another option is to query for the actual list directly from within PowerShell.

In the PowerShell instance from in the previous step notice that the output of the Import-PSSession cmdlet reports a temporary name (e.g. tmp_cmmvwal0.zrc) for the imported session.  If that output has already been cleared or scrolled off of the buffer then the following cmdlet can be used to query for it.

  • In the existing PowerShell instance run the Get-Module cmdlet to list all currently active modules.  Note the name of last entry which lists a “*-Cs*” cmdlet format under the Exported Commands field.

PS C:\> Get-Module

ModuleType Version    Name                                ExportedCommands
———- ——-    —-                                —————-
Script     5.0.0.0    LyncOnlineConnector                 {New-CsOnlineSession, Set-W…
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Conte…
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear…
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSMan…
Script     1.0        tmp_cmmvwal0.zrc                    {Copy-CsVoicePolicy, Disab…

    • Using the temporary name displayed  (e.g. tmp_cmmvwal0.zrc) issue the Get-Command cmdlet to list all of the Lync Online cmdlets which where imported into the local session.

PS C:\> Get-Command -Module tmp_cmmvwal0.zrc

CommandType     Name                                               ModuleName
———–     —-                                               ———-
Function        Copy-CsVoicePolicy                                 tmp_cmmvwal0.zrc
Function        Disable-CsMeetingRoom                              tmp_cmmvwal0.zrc
Function        Enable-CsMeetingRoom                               tmp_cmmvwal0.zrc
Function        Get-CsAudioConferencingProvider                    tmp_cmmvwal0.zrc
Function        Get-CsClientPolicy                                 tmp_cmmvwal0.zrc
Function        Get-CsConferencingPolicy                           tmp_cmmvwal0.zrc
Function        Get-CsDialPlan                                     tmp_cmmvwal0.zrc
Function        Get-CsExternalAccessPolicy                         tmp_cmmvwal0.zrc
Function        Get-CsExUmContact                                  tmp_cmmvwal0.zrc
Function        Get-CsHostedVoicemailPolicy                        tmp_cmmvwal0.zrc
Function        Get-CsHostingProvider                              tmp_cmmvwal0.zrc
Function        Get-CsImFilterConfiguration                        tmp_cmmvwal0.zrc
Function        Get-CsMeetingConfiguration                         tmp_cmmvwal0.zrc
Function        Get-CsMeetingRoom                                  tmp_cmmvwal0.zrc
Function        Get-CsOnlineUser                                   tmp_cmmvwal0.zrc
Function        Get-CsPresencePolicy                               tmp_cmmvwal0.zrc
Function        Get-CsPrivacyConfiguration                         tmp_cmmvwal0.zrc
Function        Get-CsPushNotificationConfiguration                tmp_cmmvwal0.zrc
Function        Get-CsTenant                                       tmp_cmmvwal0.zrc
Function        Get-CsTenantFederationConfiguration                tmp_cmmvwal0.zrc
Function        Get-CsTenantHybridConfiguration                    tmp_cmmvwal0.zrc
Function        Get-CsTenantLicensingConfiguration                 tmp_cmmvwal0.zrc
Function        Get-CsTenantPublicProvider                         tmp_cmmvwal0.zrc
Function        Get-CsUserAcp                                      tmp_cmmvwal0.zrc
Function        Get-CsVoicePolicy                                  tmp_cmmvwal0.zrc
Function        Grant-CsClientPolicy                               tmp_cmmvwal0.zrc
Function        Grant-CsConferencingPolicy                         tmp_cmmvwal0.zrc
Function        Grant-CsDialPlan                                   tmp_cmmvwal0.zrc
Function        Grant-CsExternalAccessPolicy                       tmp_cmmvwal0.zrc
Function        Grant-CsHostedVoicemailPolicy                      tmp_cmmvwal0.zrc
Function        Grant-CsVoicePolicy                                tmp_cmmvwal0.zrc
Function        Invoke-CsUcsRollback                               tmp_cmmvwal0.zrc
Function        New-CsEdgeAllowAllKnownDomains                     tmp_cmmvwal0.zrc
Function        New-CsEdgeAllowList                                tmp_cmmvwal0.zrc
Function        New-CsEdgeDomainPattern                            tmp_cmmvwal0.zrc
Function        New-CsExUmContact                                  tmp_cmmvwal0.zrc
Function        Remove-CsExUmContact                               tmp_cmmvwal0.zrc
Function        Remove-CsUserAcp                                   tmp_cmmvwal0.zrc
Function        Remove-CsVoicePolicy                               tmp_cmmvwal0.zrc
Function        Set-CsExUmContact                                  tmp_cmmvwal0.zrc
Function        Set-CsMeetingConfiguration                         tmp_cmmvwal0.zrc
Function        Set-CsMeetingRoom                                  tmp_cmmvwal0.zrc
Function        Set-CsPrivacyConfiguration                         tmp_cmmvwal0.zrc
Function        Set-CsPushNotificationConfiguration                tmp_cmmvwal0.zrc
Function        Set-CsTenantFederationConfiguration                tmp_cmmvwal0.zrc
Function        Set-CsTenantHybridConfiguration                    tmp_cmmvwal0.zrc
Function        Set-CsTenantPublicProvider                         tmp_cmmvwal0.zrc
Function        Set-CsUser                                         tmp_cmmvwal0.zrc
Function        Set-CsUserAcp                                      tmp_cmmvwal0.zrc
Function        Update-CsTenantMeetingUrl                          tmp_cmmvwal0.zrc

Simplifying the Process

As promised the following guidance can be used to create a script to start up the PowerShell session requiring nothing more than entering the administrator’s password.

  • Using either a simple text editor like Notepad or a more advanced tool like Windows PowerShell ISE create a new script file (e.g. LyncOnline.ps1).

  • Enter the following text into this file, replacing the highlighted example user account name with the desired administrator account for the appropriate Office 365 tenant.

Import-Module LyncOnlineConnector
$credential = Get-Credential jeff@jdskype.net
$session = New-CsOnlineSession -Credential $credential
Import-PSSession $session
Get-CsTenant | fl DisplayName

  • Save the file and then either store it in a path that PowerShell can see by default (e.g. C:\Windows) and simply invoke this script after starting a new PowerShell session.

image

This basic script will perform all of the required commands including prompting for the supplied account’s password, and then complete with an optional query of the tenant’s Display Name to (a) verify the remote connection is working and (b) list the connected tenant name which may come in handy if administering more than one tenant form the same workstation.  The last command can be omitted if desired.

By Jeff Schertz

Site Administrator

14 thoughts on “Managing Lync Online with PowerShell”
      1. As Microsoft will continue adding cmdlets as new features appear online I do not plan to keep updating this article. The setup process should remain the same but keeping all the latest cmdlets updated here would be a daunting task.

    1. Hi Jeff,

      I’m am trying to test the Office 365 Skype for Business Voice system. We currently use Polycom CX600 handsets. Do you have an idea as to if and when a firmware update will be made available so that the CX600 can work?

      Thanks.
      Andrew

      1. Current firmware will work for some O365 tenants. I’ve got a CX600 and CX3000 registered to my E3 tenant, but I’ve heard of issues from others. It is unknown if/when those devices will be officially supported with SfB Online.

  1. HI Jeff ,

    Is there any scrip to make external communication blocking Skype for Business Skype for common , which is done by user?

  2. Hi Jeff,

    I’m trying to automate running Lync BPA so I can generate an action report for team members. Standard powershell cmdlets have an “invoke-bpamodel” that I’ve been using on our DCs. Is there an equivalent command somewhere in the Lync modules? I haven’t seen one, but I also haven’t dug too deep into every module.

  3. Jeff,
    I can get contact information when I use Get-CsOnlineUser but Set-CsUser doesn’t have attribute to set it. Is there a way to modify using powershell?

    Thanks!
    Jung

  4. Is it possible to get individual call details from Skype For Business online. Since we no longer have access to the LcsCDR database I can see a way to do this ? Reports in the O365 admin only show totals and not details. Ive also tried looking at the Microsoft Graph API, online example still only show call totals and never call details.

    I have a second issue where I want to get QoE Metrics from Skype For Business online. Anyone know how to do this other than call quality dashboard. I don’t see any references to this data in the Microsoft Graph API.

    Any comments would be grateful

  5. Hi Jeff,

    This looks good, but is there’s no mention of PeowerShell core. when I do “import-module LyncOnlineconnector” in PSCore I get

    “import-module : The specified module ‘LyncOnlineconnector’ was not loaded because no valid module file was found in any module directory.”

    How do I know if that’s an error or if there really isn’t such a module for PowerShell Core?

    Thanks

Leave a Reply to Managing Office 365 with PowerShell – PowerShell-it Cancel reply

Your email address will not be published. Required fields are marked *