At this point, I don’t have a full list of Windows Server firewall exceptions for the script to run on Windows Server 2012/Lync Server 2013. I have verified it works fine if the Domain Profile is turned off. If you determine what exact exceptions are needed, please forward them. Thanks!
Tracy A. Cerise and Mahmoud Badran came up with a script to show Lync connections, and the users connected. This was quite informative as it could be used to show load balance distribution, client versions being used, and more.
I took the script and updated it a little, including:
- Removed the help function and the header block and inserted comment based help. So a user can run get-help Get-CsConnections.ps1 and get the help, just like any other script and cmdlet.
- Added a parameter to display the user list. My needs didn’t require the user list – just the statistics at the beginning. So I added the feature to show the user list by running Get-CsConnections.ps1 –IncludeUsers.
- Added a couple of functions, including one that cleans up some variables when exiting.
- Adjusted some of the formatting. I noticed things didn’t always line up when the server FQDNs were really long, like those in child domains.
- Did a prereq check to verify the Lync module is loaded. If not, it gets loaded. That way, the script will still run fine if it’s run from an ordinary PowerShell console.
- Accounted for the pool parameter being just a NetBIOS name by adding the $env:userdnsdomain to the NetBIOS name to create the FQDN. This appears to work fine if the Lync servers and user running the script are both in the same domain. If not, then an FQDN would be required.
- Renamed the script to Get-CsConnections.ps1 and some of the functions to the normal verb-noun format.
- Added a feature to show just a specific client version number, and the users connected with that client version. This can help you determine who is connecting with what versions, which is helpful when looking into licensing, upgrades, etc.
- Added support for Lync Server 2013.
- Tons more info in updates and releases following that. See the changelog for more info.
Get-CsConnections.ps1 [[-Pool] ] [-Is2013] [[-SIPAddress] ] [[-FilePath] ] [-IncludeUsers] [-IncludeHighUsers] [-IncludeSystem] [[-UserHighConnectionFlag] ] [[-ClientVersion] ] [-ShowFullClient] [ShowTotal] [[-Server] ] [-WhatIf] [-Confirm] 
Run the script specifying the front end pool or server to target:
Get-CsConnections.ps1 -pool [pool FQDN]
Get-CsConnections.ps1 -server [server FQDN]
If you’re running it against a 2013 pool or server, you MUST specify the -Is2013 switch, or the script won’t return any results.
Get-CsConnections.ps1 -pool [pool FQDN] -Is2013
If I can find an auto-detect method for server versions, I’ll include that in a later build.
Will show you unique client versions, their user agent, and the number of connections for each:
Current connected users listed by client name/version
Distribution of connections across frontend servers (load balancing):
Connections by server (load balancing)
The number of unique users and clients connected:
Total unique users and clients
And, adding the -IncludeUsers switch, such as:
Get-CsConnections.ps1 -pool [pool FQDN] -IncludeUsers
will also show the users who are connected, and the number of connections they each have:
Connections per user
Using -IncludeHighUsers instead of -IncludeUsers will only list those users who meet the UserHighConnectionFlag (shown in white) or exceed the UserHighConnectionFlag (shown in red).
Get-CsConnections.ps1 -SipAddr [sip address] -pool [pool FQDN]
Will show you the information for a single user:
Connection info for a specific user
Get-CsConnections.ps1 -pool [pool FQDN] -ClientVersion [version number]
Will show the connection data for just that version number, including listing the users connected with that client version. This is helpful if the first method lists some version numbers you’d like to track down. Here, I used a client version of 13.1. MC/13.1.x is the OCS client on the Mac.
Connections by client version
Using the -ShowFullClient option will show extended info for client name/version. However, the previous ‘Client Version’ column is not shown due to formatting restrictions. Here we can see more info, especially about mobile devices, Lync Phone Edition, and Mac clients.
Show Full Client extended info
Using -ShowTotal will also add additional info to the bottom section, including total number of users who are Lync enabled, total who are voice enabled, and percentage of total Lync enabled users who are connected.
ShowTotal option with totals and percentage
You can export the info to a .csv file for viewing/manipulation in Excel using:
Get-CsConnections.ps1 -pool [pool FQDN] -FilePath [path to csv file]
Execution Policy: Third-party PowerShell scripts may require that the PowerShell Execution Policy be set to either AllSigned, RemoteSigned, or Unrestricted. The default is Restricted, which prevents scripts – even code signed scripts – from running. For more information about setting your Execution Policy, see Using the Set-ExecutionPolicy Cmdlet.
NOTE: In order to gain remote access to each frontend server’s RTCLOCAL database where connection information is found, you need to open the local firewall for port 1434. Also, need to go into the SQL Server Configuration Manager and for RTCLOCAL, enable named pipes and restart the SQL service for the named pipes to take effect.
Port 1434 is required in order to make the connection to the named instance RTCLOCAL on the remote machines.
v2.2 05-10-2013 Get-CsConnections.v2.2.zip
v2.1 12-13-2012 Get-CsConnections.v2.1.zip
v2.0 10-16-2012 Get-CsConnections.v2.0.zip
v1.9 09-21-2012 Get-CsConnections.v1.9.zip
v1.8 09-14-2012 Get-CsConnections.v1.8.zip
See the changelog for a complete list of features added in each release