Report showing individual message count per user in Skype for Business

Our company uses O365 for all employees. One app we use within it is Skype for Business. We would like to get a report showing how many individual messages a given user sends from Skype. The MS reports only seem to provide session counts. I know in the conversation history you can see the messages sent/received, but to manually scroll through Inboxes and count these is not practical. Are there any PS scripts for this?

Thanks for the assistance in advance!
Kevin StaleyMIS AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
Try the Get-CsUserSession cmdlet, it will spill all the details you need. You can look for "[IM]" values in the MediaTypesDescription property to filter just messages.
Kevin StaleyMIS AdministratorAuthor Commented:
Thanks for the help!

In looking up where and how to run that cmdlet, I discovered I needed to download and install the "Skype for Business Online, Windows PowerShell Module," and two other installs (Visual C++ 2017 14.10.25008.0 and Win7AndW2K8R2-KB3191566-x64).

However, now that I have those in place, I tried to run the cmdlet and get an error stating, "Get-CsUserSession : The term 'Get-CsUserSession' is not recognized as the name of a cmdlet." I have tried using Windows Powershell and enter,
"Import-Module "C:\\Program Files\\Common Files\\Skype for Business Online\\Modules\\SkypeOnlineConnector\\SkypeOnlineConnector.psd1",

then I entered, "New-CsOnlineSession -UserName". I am prompted to enter my password and also a verification code (I'm using multi-factor authentication), which once entered, displays the session id and a few other session related bits of information. It is at the subsequent Windows PS prompt that I enter the cmdlet and get the error.

I am trying to do this using a Windows 7 64-bit SP1 PC.

Thanks again for the assistance!
Vasil Michev (MVP)Commented:
You need to be a SfBO admin or Global admin in order to run the cmdlet.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Kevin StaleyMIS AdministratorAuthor Commented:
I am using an account that has those privileges.
Vasil Michev (MVP)Commented:
Try a different account then? Here's how a sample output should look like:

# Get-CsUserSession -User -StartTime "01 Jan 2018" | ? {$_.MediaTypesDescription -match "\[IM\]"} |select -First 1

StartTime             : 06/11/2018 09:55:25
EndTime               : 06/11/2018 10:39:48
FromUri               :
ToUri                 :
FromClientVersion     : RTCC/ UCWA/ AndroidLync/ (WAS-LX1 Android 8.0.0)
ToClientVersion       : RTCC/ IMMCU/7.0.2229.0
ToEndpointId          :
FromEndpointId        : 8D10E0E8-AB95-5109-BCE2-87E4D413FD13
ConferenceUrl         :;gruu;opaque=app:conf:focus:id:w9bm3ycv
ResponseCode          : 200
MediaTypesDescription : [Conference][IM]
ErrorReports          : {{"RequestType":"MESSAGE","RequestTime":"2018-11-06T10:17:22.908","ContentType":"text/plain","ResponseCode":"200","DiagnosticId":24125,"ErrorCategory":"ExpectedFailure","Diagn
                        osticHeader":"24125;Component=\"RTCC/ AndroidLync/ (WAS-LX1 Android 8.0.0)\";Reason=\"IM delivery was

Open in new window

Kevin StaleyMIS AdministratorAuthor Commented:
Tried two accounts known to hold the permissions you described. Might be the Powershell I'm using. It's Windows PS 5.1. Thanks. I'll keep trying other methods.
Vasil Michev (MVP)Commented:
Well, I totally forgot that they added this to the SfBO Admin portal (too used to Microsoft Teams nowadays). So try this: Office 365 Admin Center -> Admin Portals -> Teams and SfBO -> Open legacy portal -> Reports -> Session details.
Kevin StaleyMIS AdministratorAuthor Commented:
Thanks. That looked very promising, but when I selected users who showed a fair number of a SfBO sessions in the Reports-> Usage -> Skype for Business Activity report, it returned "no data."
Kevin StaleyMIS AdministratorAuthor Commented:
Should have also said I selected a from date of about 60 days ago, so there should have been a lot of data for this user. I also tried several other users who show a higher level of SfBO activity.
Vasil Michev (MVP)Commented:
Seems to work fine for me, but it's not uncommon for reports in O365 to be missing some data. You can always open a support case to get this investigated.
Kevin StaleyMIS AdministratorAuthor Commented:
So, I just got this working in PowerShell. I used the "Windows Powershell ISE" launched as administrator. I ran this script to connect:
Set-ExecutionPolicy unrestricted
Import-Module SkypeOnlineConnector
$session = New-CsOnlineSession -UserName (replace x's with your username and tenant domain)
Import-PSSession -Session $session

I ran the cmdlet you mentioned on my own O365 account. I see the Skype activity listed. Now, what would really be helpful is to tally the total number of IM messages (not sessions) from a given start date. Is there a way to do that?
Vasil Michev (MVP)Commented:
Just save them all to a variable, then Group them by MediaTypesDescription. Something like this:

$list = Get-CsUserSession -User -StartTime "01 Jan 2018" | ? {$_.MediaTypesDescription -match "\[IM\]"}
$list | group MediaTypesDescription

Open in new window

or just filter them out

Get-CsUserSession -User -StartTime "01 Jan 2018" | ? {$_.MediaTypesDescription -match "\[IM\]"}  |measure

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kevin StaleyMIS AdministratorAuthor Commented:
Thanks so much for your assistance!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Chat / IM

From novice to tech pro — start learning today.