Home > Lync Server/Skype for Business Server > Script: Get-CsConnections.ps1 – See User Connections, Client Versions, Load Balancing in Lync & Skype for Business Server

Script: Get-CsConnections.ps1 – See User Connections, Client Versions, Load Balancing in Lync & Skype for Business Server

Lync 2013 logo 128x128Tracy 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:

  1. 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.
  2. 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.
  3. Added a couple of functions, including one that cleans up some variables when exiting.
  4. 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.
  5. 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.
  6. 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.
  7. Renamed the script to Get-CsConnections.ps1 and some of the functions to the normal verb-noun format.
  8. 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.
  9. Added support for Lync Server 2013, which uses a different query than Lync Server 2010.
  10. Tons more info in updates and releases following that. See the changelog for more info.

Syntax

Get-CsConnections.ps1 [[-Pool] ] [[-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]

or

Get-CsConnections.ps1 -Server [server FQDN]

The script automatically determines the version (2010 or 2013) of the pool, and uses the correct query.

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

Current connected users listed by client name/version

Distribution of connections across frontend servers (load balancing):

Connections by server (load balancing)

Connections by server (load balancing)

The number of unique users and clients connected:

Total unique users and clients

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

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 -SipAddress [sip address] -Pool [pool FQDN]

Will show you the information for a single user:

Connection info for a specific 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

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

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

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]

Installation

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 Front End server’s RTCLOCAL database where connection information is found, you need to open two local firewall ports; one static UDP port (1434), and one dynamic TCP port. We can use netsh to open the two required ports. First, open an elevated command prompt, and paste the following line. You should get “Ok.” in return:

netsh advfirewall firewall add rule name="SQL Browser (UDP 1434)" dir=in action=allow protocol=UDP localport=1434 profile=domain description="Created for Get-CsConnections.ps1. For more information, see https://www.ucunleashed.com/269"

Next, find the dynamically assigned port used by the Named Instance (RTCLOCAL):

  • On the Front End server, open SQL Server Configuration Manager.
  • Expand SQL Server Network Configuration.
  • Click on Protocols for RTCLOCAL.
  • On the right side, right click on TCP/IP, and choose Properties.
  • Click on the IP Addresses tab.
  • Scroll to the last section, called IPAll.
  • Note the TCP Dynamic Ports value

IPAll

Replace [dynamic port] in the code below with the dynamic port number, and run the entire following command:

netsh advfirewall firewall add rule name="SQL RTCLOCAL Dynamic Port (tcp-in)" dir=in action=allow protocol=TCP localport=[dynamic port] profile=domain description="Created for Get-CsConnections.ps1. For more information, see https://www.ucunleashed.com/269"

If you look at the inbound rules for the firewall, you’ll now see the two new rules:

fwrules

Repeat the process for both ports on each Front End server.

Note: The dynamically assigned port is unique to each Front End server, not the pool. So you’ll need find the value on each server. Once the two ports are open on each Front End server in the pool, the script should work fine.

Thanks to James Cussen for explaining what config is needed for SQL access through the firewall.

Donations

I’ve never been one to really solicit donations for my work. My offerings are created because *I* need to solve a problem, and once I do, it makes sense to offer the results of my work to the public. I mean, let’s face it: I can’t be the only one with that particular issue, right? Quite often, to my surprise, I’m asked why I don’t have a “donate” button so people can donate a few bucks. I’ve never really put much thought into it. But those inquiries are coming more often now, so I’m yielding to them. If you’d like to donate, you can send a few bucks via PayPal at https://www.paypal.me/PatRichard. Money collected from that will go to the costs of my website (hosting and domain names), as well as to my home lab.

Download

v3.5 – 08-14-2019 – Get-CsConnections.v3.5.zip

v3.4 – 03-27-2018 – Get-CsConnections.v3.4.zip

v3.3 – 01-0-2017 – Get-CsConnections.v3.3.zip

v3.2 – 11-17-2016 – Get-CsConnections.v3.2.zip

v3.1 – 04-07-2016 – Get-CsConnections.v3.1.zip

v3.0 – 09-09-2015 – Get-CsConnections.v3.0.zip

v2.9 – 10-28-2014 – Get-CsConnections.v2.9.zip

v2.8 – 06-10-2014 – Get-CsConnections.v2.8.zip

v2.7 – 05-24-2014 – Get-CsConnections.v2.7.zip

v2.6 – 02-08-2014 – Get-CsConnections.v2.6.zip

v2.5 – 11-26-2013 – Get-CsConnections.v2.5.zip

v2.4 – 09-13-2013 – Get-CsConnections.v2.4.zip

v2.3 – 08-01-2013 – Get-CsConnections.v2.3.zip

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

v1.7 – Get-CsConnections.v1.7.zip

v1.6 – Get-CsConnections.v1.6.zip

v1.4 – Get-CsConnections.v1.4.zip

v1.3 – Get-CsConnections.zip

v1.0 – Get-CsConnections.zip

Changelog

See the changelog for a complete list of features added in each release

  1. Craig
    January 20th, 2012 at 15:11 | #1

    Thanks for the script. Is it possible to show which users/connections are connected via the edge server? Mainly on the -includeusers output if you could show FE Connection – Edge Connection that would be nice. Thanks

    • Pat Richard
      January 21st, 2012 at 08:02 | #2

      That’s on the wish list for that script.

      • June 15th, 2013 at 08:25 | #3

        Hi Richard,
        Any changes to support the Edge connections ?
        Thanks

        • Pat Richard
          June 15th, 2013 at 10:22 | #4

          It already shows people connected through edge. It just don’t differentiate them. Not likely to, either. Not sure there is a way to tell based on querying SQL on the FEs.

          • December 16th, 2014 at 18:58 | #5

            At one point I wrote a web app based on Snooper66’s Find Lync versions SQL query and recall this being called isEdgeConnection there, but not sure if that was his name, or from the RTCLOCAL DB

  2. John
    February 15th, 2012 at 00:55 | #6

    Hi Pat,

    Thank you for an excellent script.

    Is it possible to show the hostname or IP address of the client connection? This would be a great help in tracking down machines running older client versions.

    Thanks.

    • March 18th, 2012 at 05:24 | #7

      Hi John,

      Yes, isn’t this a BRILLIANT script?!?!

      I’m with you – a list of client IP addresses would be a VERY handy thing to have.

      I’ve had a poke through the rtcDyn database but can’t find anything to ID the user’s endpoints. As Lync has an open connection to the client while you’re logged-in, it mightn’t even capture the hostname or IP. 🙁

      • Todd
        June 25th, 2014 at 17:26 | #8

        Has anyone determined how to map the clients to IPs? I have one client that is coming up with a BLANK VERSION and I can’t track it down

  3. Svein
    February 16th, 2012 at 08:55 | #9

    I get some errors.. Only lists connections on the server where I run the script..

    .\Get-CsConnections.ps1 -Pool lyncpool

    Checking these pool servers in pool: lyncpool.VUC.NO
    mslync01.vuc.no
    mslync02.vuc.no
    Exception calling “Open” with “0” argument(s): “A network-related or instance-s
    pecific error occurred while establishing a connection to SQL Server. The serve
    r was not found or was not accessible. Verify that the instance name is correct
    and that SQL Server is configured to allow remote connections. (provider: SQL
    Network Interfaces, error: 26 – Error Locating Server/Instance Specified)”
    At C:\Scripts\Get-CsConnections.ps1:181 char:18
    + $connection.Open <<<< ()
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "Fill" with "1" argument(s): "A network-related or instance-s
    pecific error occurred while establishing a connection to SQL Server. The serve
    r was not found or was not accessible. Verify that the instance name is correct
    and that SQL Server is configured to allow remote connections. (provider: SQL
    Network Interfaces, error: 26 – Error Locating Server/Instance Specified)"
    At C:\Scripts\Get-CsConnections.ps1:190 char:31
    + $recordcount=$sqladapter.Fill <<<

    • Pat Richard
      April 19th, 2012 at 12:23 | #10

      Svein – I haven’t forgotten about this. I’ve seen this a couple of times, and not been able to determine the issue. Still looking…

      • Corey
        April 23rd, 2012 at 20:47 | #11

        I have this same error.

        • Pat Richard
          May 17th, 2012 at 08:27 | #12

          When you open your PowerShell/Lync Management Shell session, make sure you start it as Administrator. In a couple of instances where I’ve seen the error, doing that seems to help.

          • Corey
            May 17th, 2012 at 08:38 | #13

            That did not help when I was running it.

      • Tore
        July 3rd, 2012 at 08:11 | #14

        Hi! I got the same error on my pool where I have two FE servers. It will only list the users on the FE where I run the script. (and the result i 100 % connections)

  4. Russ
    April 11th, 2012 at 00:25 | #15

    I just want to say thanks for an awesome script. This gave me EXACTLY what a manager wanted to know.

    Cheers!

  5. Jeremy
    August 15th, 2012 at 12:23 | #16

    Hi Pat, not sure if this helps but I receive the same SQL Exception error, but only on one server. It works fine on my other Front-End in the same pool – I’m using the Powershell as Administrator and using the same login credentials on both servers.

    I don’t want to just post the negatives though! This script is fantastic and it’s helped me quite a bit thus far! Thanks very much.

    • Pat Richard
      August 16th, 2012 at 11:00 | #17

      Yeah, the problem is I’m not a SQL guy. I sometimes see this problem, and sometimes it goes away. Free beer to whoever figures it out!

  6. Mike
    August 27th, 2012 at 13:18 | #18

    I was gettign teh error mentioned above, so i changed the
    #Define SQL Connection String
    [string]$connstring = “server=$server\rtclocal;database=rtcdyn;trusted_connection=true;”
    to
    #Define SQL Connection String
    [string]$connstring = “server=\;database=rtcdyn;trusted_connection=true;”

    This got rid of that connection error, but now I get ‘Nothing returned from Query’. Perhaps that isn’t the right value to change if I want to hard code the SQL server? Any ideas on what would cause the ‘Nothing returned from Query’?

    • Mike
      August 27th, 2012 at 13:23 | #19

      For some reason, what i changed it to didn’t post correctly.

      lyncserver.domain.name\lync represent my SQL server & instance name

      #Define SQL Connection String
      [string]$connstring = “server=lyncserver.domain.name\lync;database=rtcdyn;trusted_connection=true;”

  7. Pat Richard
    August 27th, 2012 at 16:21 | #20

    For those having issues, look at the comment block near the top of the script. Make sure you follow those steps, including firewall exceptions, and named pipes.

  8. Pat Richard
    September 7th, 2012 at 09:49 | #21

    Bumped to v1.7 – sorting of server names is better; -ClientVersion no longer automatically triggers -IncludeUsers; minor code optimization. Also added some installation info to the blog post.

    Still not sure what’s causing some to not work. I’m not a SQL guy, but open to suggestions.

  9. Mark
    September 12th, 2012 at 17:08 | #22

    Pat, tremendous script – many thanks! Can I make a suggestion? Have the script output all connections and their version in a table? That would be easier than asking the script to tell me every connection with a specific version. Cheers!

    • Pat Richard
      September 12th, 2012 at 18:07 | #23

      Yeah, I’ve got some ideas around that as well as targeting just specific servers within a pool. It gets real interesting when there are 15,000 people in a pool and you want to see the users. 🙂

      However, I’m working on some nagging issues that some people have reported. Hoping to get those squared away soon.

  10. Mark
    September 12th, 2012 at 18:16 | #24

    Oh, one other thing about the Installation: the because RTCLOCAL is a named instance, and assuming you’ll be connecting via TCP/IP, not named pipes (because TCP/IP normally has a higher priority when the connection type isn’t specified), the firewall needs to allow UDP 1434 (not TCP), the SQL Browser service needs to be running (I’m guessing that this is the most common connection problem) and the port that the instance is actually listening on (which can be seen in the SQL config) also needs to be open on the firewall – or just allow SQL Server. Named pipes isn’t then needed. However, if the client uses named pipes, not TCP/IP, the SQL instance does use the default named pipe, so in theory the SQL Browser shouldn’t be needed, just File and Printer sharing in the firewall. The former method doesn’t require changing the SQL server config, so I’d generally go for that.
    HTH

  11. Richard
    September 30th, 2012 at 07:55 | #25

    I just wanted to leave a short note to say thanks for creating this script, it is excellent!!

    It’s a good job there are people like you around to help the respective community in these cases where Microsoft fall short.

    Many thanks…

    R.

  12. Jacky Fan
    April 1st, 2013 at 06:04 | #26

    Hi,Pat

    Does the rtcdyn database containing the user information from which edge server it connect to ?

    If you get ideal the on which table in which column containing that information ,please share with me ,thanks

  13. Nate
    June 4th, 2013 at 16:13 | #27

    It would be awesome if this script had an option to get user information for all Pools in a domain. Then, if it had another option for how to organize that information either collectively or organized by pool, that would be amazing. Also, presumably, you should be able to get the version of Lync (2010 or 2013) and switch between differing SQL queries depending on version of the pool.

    • Pat Richard
      June 4th, 2013 at 17:07 | #28

      The problem with auto detecting the server version is that the WMI query takes at least 5 seconds. It’s really slow.

  14. July 25th, 2013 at 21:38 | #29

    Nice work Pat!

    • Pat Richard
      July 31st, 2013 at 09:42 | #30

      Thanks, John. And thanks for the testing with me the other day.

  15. Stanislaw
    September 16th, 2013 at 03:20 | #31

    Great script! Excellent! Thank you.

    I have one question according to this subject. Is there a possibility to get information about which user is doing what – I mean e.g. User1 is using Audio now, User2 is sharing his desktop etc.?

    • Pat Richard
      September 16th, 2013 at 08:58 | #32

      Not at this time. That would require extensive work.

  16. Jean-Luc
    September 17th, 2013 at 09:50 | #33

    Great script, thank you!
    I’m sorry but I don’t know “-clientversion” usage. I can’t use wildcard? I can’t see list of users who is using device/version.

    • Pat Richard
      September 25th, 2013 at 12:13 | #34

      You cannot use wildcards such as *. That’s a good request for a future version. You can feed it a shorter version number, such as 4.0.7577 to get everyone that has any version of that, including 4.0.7577.4398.

  17. Rob Hill
    October 9th, 2013 at 11:19 | #35

    Hi Pat, does this work for pool pairing where we have 2 STD servers in one site?

    • Pat Richard
      October 9th, 2013 at 11:22 | #36

      It queries the databases on the local machines in the pool. You can only specify one pool at a time, or one server at a time, or one user at a time. Within those confines, it should work. But I don’t have an environment in which to test that.

  18. JeffCSP
    October 10th, 2013 at 13:10 | #37

    Hi Richard, the last module for retrieving and displaying the assigned server order has a few bugs. 1) need to prefix sip: otherwise it is interpreted as the SamAccount. 2) Seems the selection of machineid and fqdn does not work for that property, at least it fails when running the command directly. Removing the select-object portion displays the FQDN of the machines. Appreciate all your efforts and sharing.
    Cheers,
    JeffCSP

  19. Matt
    October 21st, 2013 at 12:56 | #38

    Thank you for this script – it gives some great information that I have been looking to gather. Works well on Lync 2013 for me

  20. Juliano
    November 3rd, 2013 at 20:24 | #39

    Hi Pat Richard, I am starting to learn PowerShell. I would like to know if is possible to out the results to a file, but not the detailed information, just the informations that I see when I run the script and see the results on the screen. When I try to use the parameters -FilePatch I get the detailed results and when I use “| out-file -filepath [c:\example\example.txt] it throughs only the information, not the “headers” that shows when I see the output on the screen. Can you help me? Thanks

    • Pat Richard
      November 3rd, 2013 at 21:58 | #40

      The script does not output objects. It outputs text strings.

  21. Steve M
    November 5th, 2013 at 17:52 | #41

    Hi Pat

    Thanks for this script, it really is awesome.
    I’ve been running 2.2, 2.3 and 2.4 against Lync 2013 on Server 2012 and have been seeing this error. Results are returned, but i suspect some info is not. Do you have any ideas on a way to work around it?

    Method invocation failed because [System.Data.DataRow] doesn’t contain a method named ‘op_Addition’.
    At C:\Users\administrator\Get-CsConnections.ps1:413 char:4
    + $overallrecords = $overallrecords + $data
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException

    Steve

    • Pat Richard
      November 5th, 2013 at 17:54 | #42

      The most common issue I’ve seen is Windows firewall is blocking connections to the FEs.

      What switches are you using when calling the script?

  22. Marc
    November 7th, 2013 at 07:24 | #43

    Hi,

    It’s normal that’s not working with sba pool? Do I have to modify something?

    Thanks

    • Pat Richard
      November 7th, 2013 at 09:11 | #44

      I don’t have an SBA pool on which to test it.

  23. November 7th, 2013 at 15:54 | #45

    It works fine on my SBA, after I ran PowerShell as Administrator.

    • Marc
      November 8th, 2013 at 06:12 | #46

      Thanks for your answers, do you launch the powershell on the sba or on the FE? And you also use -pool for the sba?

      • Marc
        November 18th, 2013 at 12:06 | #47

        It’s working when I launch the script from the sba. Thanks

  24. Steve M
    November 7th, 2013 at 22:02 | #48

    Hi Pat,

    I am seeing that error in a number of environments, including my Dev lab where I have the Windows Firewall disabled. I was running the script on one of my FE’s using the -pool parameter only.

    The error implies an issue with one of your .net calls.

    Steve

  25. Tore
    November 20th, 2013 at 10:35 | #49

    Hi! I have three servers in the pool, but only get the users from one of the servers. I get this error: Method invocation failed because [System.Data.DataRow] doesn’t contain a
    method named ‘op_Addition’.
    At C:\sw\Get-CSConnections\Get-CsConnections.ps1:599 char:4
    + $overallrecords = $overallrecords + $data
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (op_Addition:String) [], Runti
    meException
    + FullyQualifiedErrorId : MethodNotFound

    Method invocation failed because [System.Data.DataRow] doesn’t contain a
    method named ‘op_Addition’.
    At C:\sw\Get-CSConnections\Get-CsConnections.ps1:599 char:4
    + $overallrecords = $overallrecords + $data
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (op_Addition:String) [], Runti
    meException
    + FullyQualifiedErrorId : MethodNotFound

    • Ben E
      March 19th, 2014 at 23:26 | #50

      Had a similar error:
      Method invocation failed because [System.Data.DataRow] does not contain a method named ‘op_Addition’.
      At C:\admin\scripts\Get-CsConnections.v2.6\Get-CsConnections.ps1:590 char:4
      + $OverallRecords = $OverallRecords + $data
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException
      + FullyQualifiedErrorId : MethodNotFound

      Caused when i had a Lync Basic client running on a Win2012r2 server. Once i logged out it went away.

  26. Pat Richard
    March 19th, 2014 at 14:04 | #51

    FYI: Client Agents that start with “LMR/”, as in “LMR/15.0.4569.1006” are Lync Room Systems.

  27. April 14th, 2014 at 15:10 | #52

    Just wanted to post and say thanks for this script, the -incudeusers function is used by me a lot, thanks!

  28. Andy Cheetham
    May 9th, 2014 at 03:26 | #53

    Pat – Great Utility. Really useful for us to quickly view how our new deployemtn of Lync 2013 is being used. Keep up the great work!

    Andy Cheetham
    IT Manager
    Morgan Advanced Materials

  29. Andy
    May 14th, 2014 at 13:24 | #54

    This would be great if you encompassed the whole thing in it’s own function so that I can put the ps1 on a network share then have my PS profile load the function for use upon opening powershell rather than having to distribute the file and running the physical file everytime i want to use it.

    • Pat Richard
      June 23rd, 2014 at 22:57 | #55

      Put it in a folder on a network share and add the share path to your computer path.

  30. Michael
    June 23rd, 2014 at 22:45 | #56

    This script has been a real help – thanks so much.

  31. kanishka
    July 15th, 2014 at 23:39 | #57

    Hi,

    Is it possible to run this script and get users connections specific only to a particular OU ?

    Thanks,
    Kanishka.

    • Pat Richard
      July 16th, 2014 at 09:26 | #58

      Not at this time.

      • Chamila
        July 29th, 2014 at 07:59 | #59

        Is it doable? and also please let me know whether this is editable to get category wise, means how many video calls, audio calls etc..

        • Pat Richard
          July 29th, 2014 at 08:18 | #60

          As I mentioned above, this script does not support that. If you want reporting, look at something like Event Zero’s Dossier product.

  32. Thierry
    July 16th, 2014 at 07:48 | #61

    line 300 of version 2.8 is not PowerShell 2 friendly:
    if (Get-Module -ListAvailable | Where-Object Name -eq “$name”) {

    I’m still learning about PowerShell so i do not have a suggestion to replace yet…
    … but if I had to guess it would look something like that:
    if (Get-Module -ListAvailable | Where-Object { $_.Name -eq “$name”}) | Select-Object {

    • Pat Richard
      July 16th, 2014 at 09:23 | #62

      Change your copy to
      if (Get-Module -ListAvailable | Where-Object {$_.Name -eq “$name”}) {
      and tell me if it works.

  33. August 12th, 2014 at 05:28 | #63

    Hello Pat,

    Great script you have here. What I would like to see per user connection what version is being used. This way we can see if the user software is upgraded from like lync 2010 to Lync 2013.

    With regards,

    Jelle

    • Pat Richard
      August 12th, 2014 at 09:54 | #64

      You can already see that with the -clientversion option.

      • August 12th, 2014 at 10:10 | #65

        Great to hear, I have tested this and it works fine, also when searching for client version like Lync 2013 you can specify -ClientVersion OC/15 and it will popup all lync 2013 clients that are connected. Great script

  34. Red
    September 24th, 2014 at 03:40 | #66

    Hi,
    without the parameter -Is2013 it does return anything. 😉

    Red.

    • Pat Richard
      September 24th, 2014 at 10:14 | #67

      Are you targeting a pool or a specific server?

  35. Mike
    October 28th, 2014 at 15:10 | #68

    This script is great and very helpful but I am now getting the error below when I try to run it:

    PS C:\> .\Get-CsConnections.ps1
    .\Get-CsConnections.ps1 : File C:\Get-CsConnections.ps1 cannot be loaded. A required certificate is not within its validity period when
    verifying against the current system clock or the timestamp in the signed file.
    At line:1 char:1
    + .\Get-CsConnections.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

    I downloaded the latest version of the script. Our execution policy is set to remote signed. I get the same error on all 3 front-end servers.

    • Pat Richard
      October 28th, 2014 at 16:26 | #69

      I released a new version today with an updated cert. Download it and give it a whirl. Thanks for reporting the issue.

  36. Mahmoud Badran
    October 29th, 2014 at 12:08 | #70

    Thanks for the recognition

  37. Amr Morsy
    October 29th, 2014 at 15:01 | #71

    Thank you, Wonderful Script, working fine, but can it help providing the IP Addresses for each device (Client) if possible

    • Pat Richard
      November 5th, 2014 at 13:09 | #72

      Not at this time.

      • Alan
        December 22nd, 2014 at 16:54 | #73

        Hello,
        This is a feature that I’m very interested in as well.
        I can see that I’m logged in from 4 different locations, but I cannot figure out where they are!

        One is my workstation, the other is my phone. I have no idea where the others are from and it’s driving me nuts.

  38. jones1337
    November 25th, 2014 at 04:02 | #74

    This script is amazing! Would it be possible to add to see which client version a particular user connection is using?

    • Pat Richard
      November 25th, 2014 at 06:30 | #75

      That’s already in there.

  39. Cormac
    January 7th, 2015 at 12:21 | #76

    Thanks so much for this 🙂 looking forward to future updates

  40. January 29th, 2015 at 05:59 | #77

    Hello Pat,

    Good job on the script and the whole post for installation,
    I have a question related to the connections – is it possible somehow to drop those for specific sipaddress/lync user ?

    We have stumbled upon a strange issue which involves both mobile clients and integration with Exchange/IM OWA access.
    Basically what happens with the client connections is that if you don’t sign off properly, for example terminate the application on the mobile device or close down the browser without signing off, the presence of this user shows as available when looking up him from the address book, though when you try to message him this generic error pops up:
    reference error ID 450 (source ID 239) a message was not delivered and got this error.
    This by the way raises as well issues with response groups when the calls are being routed to so called “available users”…

    Any ideas, maybe someone had a chance to notice this as well?

    • Pat Richard
      January 29th, 2015 at 12:53 | #78

      No plans for further filtering of users at this time.

  41. Anitaa
    February 5th, 2015 at 09:08 | #79

    Hello, There is a problem with the script. In my environment, I have 3 servers and one of them is in drain mode. Obviously there is no active conference and call hosted on this, (I have checked with the get-cswindowservice). However, when I run the script, i see on this drain-mode enabled server are connections and clients connected :). Can you fix it?

    • Pat Richard
      February 5th, 2015 at 09:42 | #80

      There is nothing wrong with the script. It shows users registered against FEs. NOT CONFERENCES. Get-CsWindowsService doesn’t show the number of registered connections.

      • Anitaa
        February 11th, 2015 at 16:00 | #81

        I didnt explain it well… So i have server A in drain mode, and server B and C – these 2 are operational. On the server A that obviously has no connection at all with any client, I run the script and i see x% connections, on the other two servers the same x% connection, but every-time is written the server name on that i am running the script. What I dont understand how is possible to have any connections or clients connected to , when the server is in drain mode?

        • February 11th, 2015 at 16:03 | #82

          If a server is draining, then there are still clients connected to it. Draining attempts to have those clients move to another FE. But as long as services are still draining, there’s likely still connections. New connections are denied, but existing ones, especially those in conferences, can continue for minutes, even hours.

  42. Animali
    April 15th, 2015 at 08:32 | #83

    My Skype for Business server pool sometimes gives empty results.
    It says: Nothing returned from query!
    Sometimes it’s been working fine, but in SfB RTM it’s not working now.

  43. Animali
    April 15th, 2015 at 08:40 | #84

    @Animali
    To reply to myself. You can use it on Skype for Business 2015 servers just fine.
    It seems that it doesn’t always recognize that its a new SfB 2015 server automatically.
    Using switch -Is2013 it gives results normally also in SfB 2015 servers.

  44. Thiago Mendes
    April 15th, 2015 at 20:22 | #85

    Good evening,

    I would like to know, if is possible to show an outcome like a table, showing like it…
    user01 — fe01
    user04— fe01
    user02 — fe02
    user03 — fe02

    • Pat Richard
      April 15th, 2015 at 21:57 | #86

      Not with this script.

  45. Juliano
    May 1st, 2015 at 11:41 | #87

    Hi. It’s a great script, but I need some help.

    It’s possible to generate a HTML file of this script?

    When I define the output file, there’s some way to only show the information that is generated to the screen and not the information about all users?

  46. May 1st, 2015 at 12:54 | #88

    @Juliano
    No such features at this time.

  47. Jeff
    May 13th, 2015 at 01:09 | #89

    Hi,

    Im getting this error below, not sure why?

    Exception calling “Fill” with “1” argument(s): “The SELECT permission was
    denied on the object ‘Registrar’, database ‘rtcdyn’, schema ‘dbo’.”
    At C:\Users\username\Get-CsConnections.ps1:284 char:2
    + $recordcount = $sqladapter.Fill($results)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SqlException

    Nothing returned from query!

    Thanks,
    Jeff

  48. Jeff
    May 13th, 2015 at 02:45 | #90

    I found the cause of my problem – Run as Administrator :). Thanks for a great post!!!

  49. Venkat
    May 15th, 2015 at 05:50 | #91

    Hi Pat, firstly thanks for the script. One query, the -server switch does not work, request to let know if this is known issue already.

    • Pat Richard
      May 15th, 2015 at 07:57 | #92

      So you specify a specific server FQDN and it doesn’t query that server?

  50. Venkat
    May 16th, 2015 at 13:37 | #93

    Thank you for the response. Yes, it does not query that server, tried from the server itself and also from another FE of the pool. Basically I’m trying to fetch the Sip address of users connected at the moment to the specific Front End. The Pool, client-version switches work well, only server switch says “nothing found from query”.

  51. Juliano
    May 17th, 2015 at 10:53 | #94

    @Pat Richard

    Hi Richard. Well. Probably I was not so clear. When I run the script it show informations with headers in screen. What I need is to get this result and generate an HTML file and attach it to an e-mail and send, but when I try to do this the result is not the same that I see on the screen. I need something like “what you see is what you get”. Only the summary to an HTML file. It is possible?

  52. May 17th, 2015 at 10:55 | #95

    @Juliano
    Not a current or planned feature.

  53. Venkat
    May 26th, 2015 at 07:17 | #96

    @Pat Richard
    Hi pat, let me know any help on the server switch of the script

  54. June 17th, 2015 at 06:03 | #97

    many thanks for good script, but is there any coming update for this script to support Skype For Business Clients??

    • Pat Richard
      September 9th, 2015 at 16:40 | #98

      Testing 3.0 now.

  55. Joe
    June 25th, 2015 at 14:32 | #99

    Is it possible to also display the department each user is in. We would like to be able to see how many users in each department are using Lync. Thanks! script is great so much cleaner and more usable then the other 3 i’ve found on the web, THANK YOU SO MUCH!!!!!

    • Pat Richard
      September 9th, 2015 at 16:40 | #100

      Not planned. That would require a substantial amount of queries to AD.

  56. Joe
    June 25th, 2015 at 14:57 | #101

    @Pat Richard

    Also curious how the script determines if someone is connected or not…. I ran the script once and got 91 unique users, I ran it again like 30min later and got 90 unique users. How does Lync determine this for the script? I know its very vague i’m still trying to understand lync backend so please bare w/ me. I’m just trying to determine how the #’s work.

    • Pat Richard
      September 9th, 2015 at 16:39 | #102

      Queries the databases in Lync/Skype4B for the info. That’s all.

  57. Mike
    July 8th, 2015 at 13:26 | #103

    Hello Pat,

    the Script Autodetect feature currently doesn’t recognize the new Skype for Business Server but if you use the -is2013 switch it still works.

    The Autotectect line should be modified to include the new Server

    For Example:
    Old: if (($PoolFqdn -and (Get-CsService -PoolFqdn $PoolFqdn -Registrar).Version -eq 6) -or $Is2013){

    New: if (($PoolFqdn -and ((Get-CsService -PoolFqdn $PoolFqdn -Registrar).Version -eq 6 -or (Get-CsService -PoolFqdn $PoolFqdn -Registrar).Version -eq 7)) -or $Is2013){

    Also a -noupdate switch would be nice. It is sometimes annoying if you have to do multiple different queries and always get asked for the update check.

    Greetings

    Mike

    • Pat Richard
      September 9th, 2015 at 16:38 | #104

      I’ve got a similar method queued up for 3.0.

      Thinking about the update suggestion…

  58. Robinhood
    July 27th, 2015 at 11:28 | #105

    Hi Pat,
    Amazing, Just amazing. Was looking for a cmdlet to show active users and boom !! Your site came up. It would be a plus if It could separate external users from Internal users. But awesome job.

  59. Steve
    August 24th, 2015 at 20:49 | #106

    Hi Pat

    Love your script, it’s fantastic.

    Is there a way of suppressing the update check?

    Steve

  60. August 27th, 2015 at 04:04 | #107

    Useful script..Thanks Tracey and Mahmoud

  61. Sebastian
    September 9th, 2015 at 10:51 | #108

    Hi Pat! first of all thank you for you script!

    Is there any way to manually specify a list of Servers? The thing is that I have multiple Registrar Servers to query (most of them are SBS), and as each of them is a pool itself I need to query one by one with the actual script.

    Thanks in advance for your answer!

  62. Per Bendixen
    November 19th, 2015 at 06:57 | #109

    Hi Pat
    Thanks for a fantastic script
    Do you know how to remove at connection for a user, when the user has lost his device?

  63. December 2nd, 2015 at 20:47 | #110

    This script proved to be most useful in troubleshooting today. We had the FE service on one of our servers lock up, and could not figure out why some users could not connect. I ran this script and it listed all the FE servers in a particular pool except one, that was our culprit. We have five Lync pools globally, two with ten FE servers each, the other three with 3-5 FE servers each. Is there a way to make this query all configured Lync pools? My management would like me to automate this, and I have everything except getting all the information in a single file.

  64. Boris
    December 16th, 2015 at 10:08 | #111

    Hi,
    I was running this script and got the following error:
    Exception calling “Fill” with “1” argument(s): “The SELECT permission was
    denied on the object ‘Registrar’, database ‘rtcdyn’, schema ‘dbo’.”
    At Get-CsConnections.ps1:284 char:2
    + $recordcount = $sqladapter.Fill($results)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SqlException

  65. Ucwarrior
    January 5th, 2016 at 14:19 | #112

    Is it possible to see connections coming in via edge server?

    • Pat Richard
      January 5th, 2016 at 15:31 | #113

      Not with this script.

  66. LordStark11
    January 7th, 2016 at 14:22 | #114

    I have 2 Enterprise Edition pools. Each is configured identically. The script pulls data for pool A, but I get no data returned from query for Pool B. I have checked all settings on each server and they are identical as far as the SQL Server Configs. Firewalls are set to allow 1434. What could I be missing. I know that users are connected to Pool B. Thanks for the help and the script is awesome on the pools it works on. Great work.

  67. jim smith
    January 11th, 2016 at 18:17 | #115

    @Pat Richard
    My Issue……..

    So I have 3 servers in my FE pool.

    I issue the drain command to the one I wish to patch/reboot/pick a function.

    I can run this script to find out Who and What Cs-User is registered to the FE I wish to work on.

    Short of killing the services on the server how do I gracefully move the active connected client/users to a different front end?

    Ideas?????

    • Pat Richard
      January 11th, 2016 at 18:39 | #116

      Client will move over when you drain, but current calls and conferences don’t. So you need to wait for them to end, if you want it done gracefully.

  68. Javier Martínez
    January 29th, 2016 at 14:29 | #117

    Dear Pat, congratulations this is a great script. It help me a lot!.

    I tested it on Skype Server 2015 and worked fine.
    Also work fine using a SBA pool.

    Even this work fine detecting phone firmware. I am using Snom Phones on my deployment and the script can identify the firmware versión of the devices.

    best regards,
    Javier

    • Pat Richard
      January 29th, 2016 at 14:30 | #118

      Thanks – just realize that Snom has withdrawn from the Lync/Skype for Business space. Not sure how much longer you’ll see updates from them.

  69. Dino
    March 3rd, 2016 at 12:33 | #119

    Hey Pat – is there any way to suppress the “This version is older than 90 days , do you want to check message”? If you run this in a scheduled task it hangs up on this.
    Thanks
    Dino

    • Pat Richard
      March 3rd, 2016 at 12:41 | #120

      What version of the script are you running?

  70. Ginbo
    March 29th, 2016 at 08:21 | #121

    Hi Pat,

    would it be possible to add the functionality to check multiple pools at once?
    We would like to add an array of pools as standard value in the param block, but unfortunately that doesn’t work without changing the whole script.
    We have two enterprise pools and a consolidated view would be great.

  71. Amrelmorsy
    April 1st, 2016 at 10:40 | #122

    Hello Pat

    I had some remote SBS/SBA where the Firewall port was blocking the Script from Running, I checked online for a while and I was able to put together this code to Remotely Enable the Ports on the Firewall on the assumption that the WinRM is configured to allow remote management WMI

    Thanks to Allen White Blog Post

    http://sqlblog.com/blogs/allen_white/archive/2011/05/21/find-your-enabled-sql-server-network-protocols-using-powershell.aspx

    The Code below might be useful for you

    Function OpenRTCPorts {
    Param(
    [Parameter(Mandatory=$True, HelpMessage=”Server Name: “)][string]$Server)
    Function RTCDynamicPort {
    Param(
    [Parameter(Mandatory=$True, HelpMessage=”Server Name: “)][string]$Server)
    [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SqlWmiManagement”) | out-null
    [System.reflection.assembly]::LoadWithPartialName(“Microsoft.SqlServer.Smo”) | out-null
    $m = New-Object (‘Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer’) “$Server”
    $RTCinst = $m.ServerInstances |? Name -eq RTCLOCAL
    $proto = $RTCinst.ServerProtocols |? DisplayName -eq ‘TCP/IP’
    $IPALL=$Proto.IPAddresses |? Name -eq IPAll
    $DynPort=($IPAll.IPAddressProperties |? Name -eq TcpDynamicPorts).Value
    $Output=new-object -typeName psobject
    $Output |add-member -membertype NoteProperty -Name “ServerName” -Value $server -Passthru |out-Null
    $Output |add-member -membertype NoteProperty -Name “Instance” -Value “RTCLOCAL” -Passthru |out-Null
    $Output |add-member -membertype NoteProperty -Name “DynamicPort” -Value $DynPort -Passthru |out-Null
    $Output
    }
    $Serverconnection=RTCDynamicPort $Server -ea SilentlyContinue
    $Port=$Serverconnection.DynamicPort
    write-host “Connections on this Server will use the SQL Browser UDP Port 1434 and the below Parameters for TCP”
    $ServerConnection
    if ($port -ne $Null) {
    $StaticRule=@”
    netsh advfirewall firewall add rule name=”SQL Browser (UDP 1434)” dir=in action=allow protocol=UDP localport=1434 profile=domain description=”Created for Get-CsConnections.ps1.”
    “@
    $Rule=@”
    netsh advfirewall firewall add rule name=”SQL RTCLOCAL Dynamic Port (tcp-in)” dir=in action=allow protocol=TCP localport=$Port profile=domain description=”Created for Get-CsConnections.ps1″
    “@
    $OldStatic=’netsh advfirewall firewall show rule name=”SQL Browser (UDP 1434)”‘
    $OldStaticValue=iex “Invoke-Command -ComputerName $Server -ScriptBlock {$OldStatic}”
    $OldDynamic=’netsh advfirewall firewall show rule name=”SQL RTCLOCAL Dynamic Port (tcp-in)”‘
    $OldDynamicValue=iex “Invoke-Command -ComputerName $Server -ScriptBlock {$OldDynamic}”
    write-host “Trying to configure the Dynamic TCP Port: $Port”
    if (($OldDynamicValue -match $port).Count -eq 0 ) {iex “Invoke-Command -ComputerName $Server -ScriptBlock {$Rule}”}
    elseif (($OldDynamicValue -match $port).Count -gt 0 ) {write-host “Rule already Existing”}
    write-host “Trying to configure the SQL UDP Port: 1434”
    if (($OldStaticValue -match 1434).Count -eq 0 ) {iex “Invoke-Command -ComputerName $Server -ScriptBlock {$StaticRule}”}
    elseif (($OldStaticValue -match 1434).Count -gt 0 ) {write-host “Rule already Existing”}
    }
    elseif ($port -eq $Null) {write-host “WinRM might not be Enabled for this Server or Server may not be reachable”}
    }

  72. Pat Richard
    April 7th, 2016 at 13:21 | #123

    @LordStark11
    Make sure you have BOTH firewall ports open. The static UDP/1434 and the dynamic port.

  73. April 14th, 2016 at 07:55 | #124

    Is there anyway to return the IP of a given set of versions. Example: We just released 5.3.2 to our VVX 600 phones. When i run your script i see there are 81 phones out there somewhere that have not taken the update for one reason or another.

    Anyway to pull the IP info associated with those 81 endpoints out of SQL?

    I suspect that the EVENTZERO product may help with some of this however if some rouge IT person just points a phone at my lync environment and doesn’t point the phone at the EVENTZERO product, i don’t think eventzero would even see this phone, thus this data must be in SQL somewhere.

  74. Pat Richard
    April 14th, 2016 at 09:59 | #125

    @Ryan
    You can list the users, which is as close as I can currently get. Keep in mind that the “rogue IT person” would have to hard code some config in the phone, since Event Zero’s solution uses DHCP to point the phones at the provisioning bridge.

  75. Paul
    April 17th, 2016 at 08:21 | #126

    Great script, but wondering about the -includeUsers option. It seems to be mis-reporting because if I look at my connections it shows 3, but I’m only signed into Lync at one endpoint.

    Can you explain that?

    • Pat Richard
      April 17th, 2016 at 23:03 | #127

      Outlook with Lync connectivity? Phone? Break down the client versions, and you can generally figure out where they’re coming from.

  76. Ben Timms
    April 19th, 2016 at 00:41 | #128

    Great script!! It is good that you can find what user agents a particular person has, but I am wondering if it is possible to do the reverse – find who is using a particular user agent? I don’t think it is currently a feature of this script. You can find what Client version but not user agent.

    I mention this because we use the Lync 2013 VDI plugin which actually reports as the same Client Version as the thick client but the user agent is different.

    Our use case is to identify people who need to patch their client in a BYOD environment.

    Also ability to check who is connected via Edge would be great!!

    Thanks!!

  77. Ben Timms
    April 22nd, 2016 at 01:22 | #129

    Great script! We use the Lync 2013 VDI Plugin which actually has a different user agent to the main client, however the ‘Client Version’ is exactly the same. As such we cannot easily identify who is using a particular version of the Lync 2013 VDI Plugin – would it be possible to include a filter for User Agent?

    Also it would be great to see who is connected via Edge!

    Cheers 🙂

  78. May 17th, 2016 at 13:45 | #130

    I don’t see where this will list out all the ‘Unique Active Users’. Is that possible? Would I be able to show Unique Active Users over the past month? Trying to control licenses.

    • Pat Richard
      May 17th, 2016 at 15:25 | #131

      -IncludeUsers will show currently connected users. The script does not show historical data, and there are no plans to do that. It queries servers in real time.

  79. Ramkumar
    June 23rd, 2016 at 05:32 | #132

    @Juliano
    Hi Do you have the script to send the results through email

    • Pat Richard
      June 23rd, 2016 at 16:07 | #133

      No. And no plans to add it.

  80. John
    July 11th, 2016 at 22:23 | #134

    Thanks Pat for the script, had some similar SQL queries before, but the convenience of your PowerShell script goes a long way.

    People frequently have been looking for the IP address of a device. I’ve only seen it in the monitoring DB. If we take your SQL query and modify it a bit, we get the EndpointID (I’ve also included the ExpiresAt portion since that is helpful for addressing some other items).

    Select (cast (RE.ClientApp as varchar (100))) as ClientVersion, R.UserAtHost as UserName, RA.Fqdn, EP.ExpiresAt, EP.EndpointId
    From rtcdyn.dbo.RegistrarEndpoint RE
    Inner Join rtcdyn.dbo.Endpoint EP on RE.EndpointId = EP.EndpointId
    Inner Join rtc.dbo.Resource R on R.ResourceId = RE.OwnerId
    Inner Join rtcdyn.dbo.Registrar RA on EP.RegistrarId = RA.RegistrarId
    where R.UserAtHost = ‘xxxx@sipdomain.com’
    Order By ClientVersion, UserName

    Anyhow, once you have this, you have the EndPointID.

    Then if you run this against the LcsCDR database on your monitoring server
    select TOP 1 IpAddress
    FROM Registration
    where EndpointId = ‘xxxxxx_from_previous_step_xxxx’
    ORDER BY LastModifiedTime DESC

    Not sure if it is perfect, but has worked the few times I needed it.

    In order to tie into your script, would suspect would need a linked server defined in the RTCLOCAL instance pointing to the monitoring server, etc. Not a trivial undertaking, but the manual queries aren’t horrible if you really need it. Worse case, could add a variable in the script (could be passed param) for the monitoring DB server name and run the query against it in a similar fashion as the first query, just passing in a param from each row of the first query’s results (which would be slow…only recommend when querying against a particular SIP address). But would speed up the manual lookup process at least.

    Thanks.

  81. H L
    August 2nd, 2016 at 08:28 | #135

    Hi when I do server-work I would sometimes like to know how many users that has been active the last 30 minutes so I can estimate impact on a larger change. Can you add something for this?

    • Pat Richard
      August 2nd, 2016 at 14:13 | #136

      The script reads data in real-time, from the servers. Historical data is not retained.

  82. Bruno
    August 17th, 2016 at 15:41 | #137

    Please add support to displaying how many video calls / audio calls / chats are being held

    • Pat Richard
      August 17th, 2016 at 15:48 | #138

      That’s not likely to happen. It’s not designed to be an analytics tool. It’s merely a troubleshooting tool. If you want full analytics, try Event Zero’s UC Commander.

  83. Folkert Datema
    September 1st, 2016 at 07:37 | #139

    Hi Pat, thanks for the great script. I tested the 3.1 version on a Lync2013 pool, but the Get-CsConnections.ps1 -PoolFqdn poolname -ClientVersion version won’t give any sip addresses of users. Only the amount of connections. Is that part removed?

    • Pat Richard
      September 1st, 2016 at 08:00 | #140

      Try using the -IncludeUsers option.

  84. Folkert Datema
    September 1st, 2016 at 08:29 | #141

    Yes, that did it! Thanks.

  85. Werner Broedrich
    October 27th, 2016 at 10:00 | #142

    Hi – ive been using this script for ages, and always just worked. However after trying to run against a 2 server SfB pool, I only get one server (server 1) returned in the “FrontEnd Server” section (the bit that shows how many connections per server)

    The script does detect both servers though, just doesn’t display both within before mentioned.
    If I stop the RTCSRV service on server 1, both show up temporarily, and once the service is stopped, the only server 2 is displayed. When I then start this service again on server 1 – server 2 disappears and server 1 is then displayed again (only).

    Any idea?

  86. Frank
    November 17th, 2016 at 09:22 | #143

    Hi Pat, just recognized that the signing certificate for the beloved Get-CsConnections.ps1 expired. Might it be possible for you to publish a new signed version? Would be appreciated. Thanks in advance.

  87. SussexMan
    November 18th, 2016 at 10:31 | #145

    Thanks for the new 3.2 version.
    However it isn’t working for me…. it errors on line 345

    • November 18th, 2016 at 10:32 | #146

      Without telling me the exact error, I can’t even begin to look at it.

  88. SussexMan
    November 18th, 2016 at 10:44 | #147

    The “=” operator is missing after a named argument.
    At C:\lyncscripts\Get-CsConnections.ps1:345 char:40
    + [CmdletBinding(SupportsShouldProcess, <<<< SupportsPaging)]
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingEqualsInNamedArgument

  89. SussexMan
    November 18th, 2016 at 10:47 | #149

    Name Value
    —- —–
    CLRVersion 2.0.50727.5485
    BuildVersion 6.1.7601.17514
    PSVersion 2.0
    WSManStackVersion 2.0
    PSCompatibleVersions {1.0, 2.0}
    SerializationVersion 1.1.0.1
    PSRemotingProtocolVersion 2.1

    • November 18th, 2016 at 10:49 | #150

      Yeah, you might want to upgrade PowerShell to something that’s not 10 years old. You’re 4 versions behind.

  90. SussexMan
    November 18th, 2016 at 10:51 | #151

    Ok, hadn’t realised there was a minimum version.
    I’ve gone back to v3.1 for now, that’s working fine. Thanks.

  91. Shady
    November 18th, 2016 at 20:52 | #152

    Thanks Pat for the new version.

  92. ldm
    November 24th, 2016 at 04:01 | #153

    Hi I have the strange problem that I find the same user using multiple versions…
    When I do this I find a certain user
    ./Get-CsConnections.ps1 -Pool lyncpool01.xxx.xxx -ClientVersion 4797 -IncludeUsers
    when I do this I find the same user
    ./Get-CsConnections.ps1 -Pool lyncpool01.xxx.xxx -ClientVersion 4875 -IncludeUsers

    • November 29th, 2016 at 12:19 | #154

      The same user could have multiple clients across multiple machines, including mobile.

  93. EML
    December 12th, 2016 at 06:30 | #155

    Hi Pat. What will be the easiest to get the output sent to an email in HTML?

    • December 12th, 2016 at 12:05 | #156

      In theory, you could try piping the script to New-MailMessage. But I’ve not tried that.

  94. Mark
    January 4th, 2017 at 10:40 | #157

    Hello,

    the 3.1 version is not working atm, gives error:

    .\Get-CsConnections.ps1 : File G:\Data\Scripts\Skype\Get-CsConnections.ps1 cannot be loaded. A required certificate is not within its validity period when verifying against the
    current system clock or the timestamp in the signed file.

    Th 3.2 version is working but is also giving an error:

    Exception calling “DownloadString” with “1” argument(s): “Unable to connect to the remote server”
    At G:\Data\Scripts\Skype\Get-CsConnections.ps1:351 char:5
    + [xml] $xml = (New-Object System.Net.WebClient).DownloadString(“http://www.eh …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

    I’m using Skype for Business 2015 with November 2016 CU.

    What could go wrong here?

  95. Mark
    January 4th, 2017 at 10:44 | #158

    Hello,

    the 3.1 version is not working atm, gives error:

    .\Get-CsConnections.ps1 : File G:\Data\Scripts\Skype\Get-CsConnections.ps1 cannot be loaded. A required certificate is not within its validity period when verifying against the
    current system clock or the timestamp in the signed file.

    I’m using Skype for Business 2015 with November 2016 CU.

    What could go wrong here?

  96. Ary Lima
    January 13th, 2017 at 16:15 | #161

    Hello

    I need to check the last access of the user in lync, is it possible?

  97. Mike
    January 22nd, 2017 at 19:15 | #163

    Hello Pat

    the new update mechanism ignores the -skipupdatecheck parameter. The servers in question are behind a firewall that blocks most internet access with some exceptions and because of this the script is slow until it runs into a timeout and writes “Exception calling “DownloadString” with “1” argument(s): “Unable to connect to the remote server””

    After this message i get the expected result with the connection table.

    If -skipupdatecheck is set it shouldn’t even try to establish a connection to the update server.

    Greetings

    Mike

  98. Mike
    January 30th, 2017 at 23:56 | #164

    Hi Pat

    It looks like the script (v.3.3) does not support multiple values from the pipeline.
    E.g.
    Get-CsService -Registrar | .\Get-CsConnections.ps1
    picks up only the first pool

    Amazing script – I use it every day!

    Regards
    Mike

  99. Ralf
    January 31st, 2017 at 06:31 | #165

    @Mike

    Hello,

    i added the following in function Get-UpdateInfo {}

    Line 352 …
    [string] $article
    )
    if (-Not ($SkipUpdateCheck)){

    Line 385…
    }
    } # end function function Get-UpdateInfo

    Now it is working if I gibe the parameter -SkipUpdateCheck

    hth,
    Ralf

    • January 31st, 2017 at 12:50 | #166

      Yeah, I’ve already got it queued up for the next version, along with some other tweaks.

  100. soder
    February 24th, 2017 at 05:09 | #167

    +1 for implementing (and honoring) a switch for ignoring the online update check function!

  101. Jameson Pugh
    March 6th, 2017 at 09:35 | #168

    Have you considered publishing this to PSGallery, so it can be installed via Install-Script?

  102. James
    March 30th, 2017 at 08:15 | #170

    Hi Pat,
    Great Script, We tried with Skype For Business Server.Please suggest which parameter we should use to get user connections via Edge Server ?

  103. Michael Pesin
    May 22nd, 2017 at 16:02 | #172

    Thanks for the script

    Im getting the following error

    The “=” operator is missing after a named argument. Can you help?

  104. Richard
    July 5th, 2017 at 11:44 | #173

    Hi pat,
    My apologies for being vague but you seem the type of guy that might be able to answer this. I need to replicate the monitoring reports provided in sfb server 2015 but hook them to our org hierarchy – this is simple enough if I had the username – so for example, to replicate the peer to peer registration summary per service, team etc, I would need the detail data for this… is there a way of getting this?? I am aware of the peer to peer session log per user report but it’s quite limited to what it can provide.

    Any help/advice is greatly appreciated!

    Thanks

    Rich

  105. Sebastian
    July 24th, 2017 at 11:20 | #174

    Many thanks for the script and the result of “-ShowTotal” is it possible to save it to a text file? “-FilePath” only saves the total number of users.

  106. Austin Caldwell
    August 7th, 2017 at 10:39 | #175

    Hi,

    First off, thanks for providing this excellent script! I am wanting to utilize this script to create .csv files based on Agent type. For instance, I’d like to run something like this to return a list of iPhone endpoints .\get-csconnections.ps1 -showfullclient | where {$_.Agent -like “iPhone”} – FilePath C:\iphone.csv Unfortunately, that bit of code did not achieve the desired result. Is something like this possible? Thanks!

  107. Austin Caldwell
    August 10th, 2017 at 10:20 | #176

    @Austin Caldwell
    I answered my own question. As it did not look to be possible to do this directly from the script, I just wrote a separate script which pulls the CSV files which have been generated for each pool with the -ShowFullClient parameter and then appends the desired information to a single CSV document. It then gives me a count of the connected endpoints. In case anyone wants to do something similar, here’s what that looks like:

    Write-Host “Creating Endpoint CSV Files”

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*iphone*”} | Export-csv C:\iphone.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*iphone*”} | Export-CSV -Append -Path C:\iphone.csv

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*iPad*”} | Export-csv C:\ipad.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*iPad*”} | Export-CSV -Append -Path C:\ipad.csv

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*Mac*”} | Export-csv C:\mac.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*Mac*”} | Export-CSV -Append -Path C:\mac.csv

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*Android*”} | Export-csv C:\Android.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*Android*”} | Export-CSV -Append -Path C:\Android.csv

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*OWA*”} | Export-csv C:\OWA.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*OWA*”} | Export-CSV -Append -Path C:\OWA.csv

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*SIPE*”} | Export-csv C:\SIPE.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*SIPE*”} | Export-CSV -Append -Path C:\SIPE.csv

    Import-Csv C:\pool1.csv | Where-Object {$_.ClientVersion -like “*OC*”} | Export-csv C:\Windows.csv

    Import-Csv C:\pool2.csv | Where-Object {$_.ClientVersion -like “*OC*”} | Export-CSV -Append -Path C:\Windows.csv

    Write-Host “Counting Endpoints”

    Write-Host “iPhone:”
    (Import-Csv C:\iphone.csv).count

    Write-Host “iPad:”
    (Import-Csv C:\ipad.csv).count

    Write-Host “Mac:”
    (Import-Csv C:\mac.csv).count

    Write-Host “Android:”
    (Import-Csv C:\Android.csv).count

    Write-Host “OWA:”
    (Import-Csv C:\OWA.csv).count

    Write-Host “SIPE/Pidgin:”
    (Import-Csv C:\SIPE.csv).count

    Write-Host “Windows:”
    (Import-Csv C:\Windows.csv).count

    Pause

  108. Korbyn
    October 4th, 2017 at 16:03 | #177

    Suggestion: Be able to report the users or versions connected to a particular server in a FE pool. Found a possible problem with one node, but can’t determine who’s on just that one node, and possibly their client versions (iOS issues…)

  109. Quynh Ho
    October 18th, 2017 at 05:41 | #178

    Thanks Pat, do you think how this can be modified with the Skype for Business Online version.
    it also has the registrapool but I have no idea to retrieve its client version,etc…do you have any suggestion.

  110. Carl S
    November 8th, 2017 at 04:24 | #179

    wonderful script !!!
    i am looking to integrate this with my prtg system for sfb monitoring 🙂

  111. Almantas
    January 8th, 2018 at 04:49 | #180

    I can get connected users and connections, but is there possible to get computers name a user is connecting from?

  112. Almantas
    January 9th, 2018 at 04:40 | #181

    (Get-WmiObject -Class Win32_ComputerSystem -Property Name).Name – returns hostname of windows machine.
    I can’t think of how to integrate this into the suggested script to print hostname if it is windows pc.

  113. Lee
    January 11th, 2018 at 14:00 | #182

    Hi Pat, Thank you so much for this brilliant script!!!
    I understood that right now there is no possibility to track Edge users or see external client ip, BUT propably U can suggest what table/parameter I can query (propably to Edge SQL) to see Edge users/external ip?

  114. Korbyn
    April 4th, 2018 at 19:18 | #183

    Script Idea… can you pull the IP address of the connected endpoint? don’t know if that’s buried in the DB somewhere, or if it’s only recorded with the CDR.

  115. soder
    April 16th, 2018 at 05:30 | #184

    I have an issue with v3.4 (did not test with older, but they may also be affected):

    Skype Meeting room accounts throw an error (a normal CSUSER was converted into CSMEETINGROOM with Enable-Csmeetingroom):

    Get-CsUserPoolInfo : Cannot find user in Active Directory with the following SAM account name:
    “sip:CSMEETINGROOM01@domain.com”
    At C:\Users\admin\Desktop\Get-CsConnections_v3.4.ps1:1215 char:26
    + $UserPreferredInfo = Get-CsUserPoolInfo -Identity sip:$SipAddress | Select-O …

  116. Ant
    May 8th, 2018 at 00:53 | #185

    Is it possible to list up the IPAddresses associated with every user?

  117. Patrick
    July 20th, 2018 at 13:40 | #186

    Is ther a way to pull a list of users with the client versions they are running per pool?

  118. Sunil
    August 6th, 2018 at 13:36 | #187

    Thanks for the script Pat! Do you have any scripts for Skype for business online? If yes, could you please share them or send me the link to download please? Appreciate your help in advance.

  119. Michael Kallhoff
    August 29th, 2018 at 16:30 | #188

    So, if i’m reading this right, and i very well may not be, it almost sounds as though you need to repeatedly open firewall ports? if i’m missing something, please, let me know. but these dynamic sql ports that you’re assigning, don’t they change every time the services are restarted or the server is rebooted?

    • August 29th, 2018 at 19:18 | #189

      Dynamic ports don’t change. They’re just randomly chosen when SQL is first installed. You only have to open them once.

  120. Jonathan
    September 25th, 2018 at 10:16 | #190

    Hi Pat
    Do you have any figures on performance? ie running against a full pool of 80,000 users and 12 servers in a pool?

    Kr

  121. tiger
    December 25th, 2018 at 02:00 | #192

    Is it possible to list up the IPAddresses associated with every user?

    • December 25th, 2018 at 12:14 | #193

      One of these days, if I can figure out a valid SQL query, it might be possible.

  122. Michail
    June 11th, 2019 at 15:05 | #194

    After last CU key -server stop worked.
    -pool work fine and found all server and users, but can’t show single server logging users

    Nothing returned from query!

  123. Luca M
    November 21st, 2019 at 05:23 | #195

    Hi Pat, many thanks for this awesome script.
    I have to make a test with one of my users and to do that, she has to be “Offiline” in Skype. She normally uses Skype for Business with a Laptop and an iPhone. If she logoff from both the devices, I still can see a session UP (iPhone app agent) and consequently I see always the user in the yellow state “Away – Mobile” even if she hasn’t any other Apple mobile devices.
    Is there any way to kill all the active sessions of a specific user?
    Many thanks for the support!

  124. Steve W.
    March 15th, 2021 at 15:12 | #196

    Great script! Any plans to make this work with SfB 2019?

  125. wisu20
    September 23rd, 2022 at 05:06 | #198

    Hi Richard, thanks for the script. Is it possible to get all connected users a day?

  126. September 23rd, 2022 at 20:09 | #200

    @wisu20
    If you query the last login time it will reveal who’s logged in within the last ‘n’ hours, which I think meets your criteria?

    There are a couple of approaches you can take, either PS or SQL:
    https://ucsorted.com/ps-one-liners/
    https://learn.microsoft.com/en-us/answers/questions/267274/how-to-list-skype-accounts-with-the-lastlogon-time.html

  1. November 19th, 2011 at 15:42 | #1
  2. January 18th, 2012 at 04:13 | #2
  3. March 17th, 2013 at 12:03 | #3
  4. May 13th, 2013 at 20:33 | #4
  5. June 30th, 2013 at 02:12 | #5
  6. May 1st, 2014 at 23:14 | #6
  7. June 10th, 2014 at 09:33 | #7
  8. October 28th, 2014 at 18:08 | #8
  9. December 8th, 2014 at 18:02 | #9
  10. May 25th, 2015 at 06:55 | #10
  11. October 22nd, 2015 at 08:09 | #11
  12. May 12th, 2016 at 18:22 | #12
  13. August 10th, 2016 at 16:28 | #13
  14. July 7th, 2017 at 19:58 | #14
  15. March 14th, 2018 at 15:11 | #15
  16. March 27th, 2018 at 22:15 | #16
  17. June 6th, 2018 at 05:17 | #17
  18. September 9th, 2018 at 18:09 | #18
  19. February 19th, 2019 at 09:27 | #19
  20. July 24th, 2019 at 00:24 | #20