Real-Time UC

A Universal Communications Blog by Office Apps and Services MVP Michael LaMontagne

Lync Office365 Projects Scripts Skype for Business

Get-CSUserSessionDomains: Extract a list of domains used in communication from Skype for Business Online user session data

Get-CSUserSessionDomains is a PowerShell script leveraging the Get-CSUserSession cmdlet in Skype for Business Online to extract a list of unique domains used in communication from user session data. The Get-CSUserSession cmdlet exposes session details for Registration/IM/Audio/Conference/Video, unlike the Skype for Business Online Admin Portal corresponding tools.

Get-CSUserSessionDomains which can be found on the TechNet Gallery. Script Download: Get-CSUserSessionDomains.ps1 https://gallery.technet.microsoft.com/Get-CSUserSessionDomains-c8b0257c

A few items to note when working with the base Get-CSUserSession cmdlet:

  • Timestamps are in UTC time.
  • If a single user query results in over 1000 results, only the oldest 1000 will be returned.
  • Warnings like to spew all over the console, -WarningAction silentlycontinue could be your friend.
  • I wrote a PowerShell GUI wrapper for this cmdlet previously: Get-CSUserSessionGUI

A shoestring version of Get-CSUserSessionDomains was created last year in response to a question received by Mark T. to my LinkedIn account. The original ask was if I had a way to extract all users’ contacts in Skype for Business Online to generate a list of federated domains. After a few thoughts and first suggestion of using my Invoke-SFBContacts in a login script to dump users’ contact list to a shared drive and use a PowerShell script to pull all the unique SIP domains from the files on the share. After sleeping on the issue, I came up with an alternative! Performing open heart surgery on Get-CSUserSessionGUI to loop through all users vs. one and to pull only the domains listed in the from/to within the user session data. The result was a list of domains used in actual communication vs. stale or incorrect items on a contact list that might not be used. Mark T. response was this returned data that they were told from Microsoft wasn’t possible to capture and I solved their issue.

Fast forward to today, Get-CSUserSessionDomains is a completely rewritten script from the ground up with no GUI or bloated code. By default the script will just prompt for Skype for Business Online administrative credentials and loop through all users’ session data for the last week and output an array of unique domains extracted from the session data. Instead of running against all users, specify a single sip address to the -SipAddress parameter. Instead of running for 1 week, use a Format of ‘Number Unit’ for the -Duration parameter.

  • Examples : ‘30 mins’, ‘45 minutes’, ‘1 hr’, ‘2 hours’, ‘1 day’, ‘2 days’, ‘1 week’, ‘2 Wks’, ‘1 Mon’, ‘2 Months’, ‘1 yr’, ‘2 years’

Get-CSUserSessionDomains has two prerequisites:

It took about 22 minutes to parse 1400 users with 30K worth of sessions in a week.

Script Download: Get-CSUserSessionDomains.ps1 https://gallery.technet.microsoft.com/Get-CSUserSessionDomains-c8b0257c

Hugo-Octopress Theme | Powered by Hugo