Use CLI for Microsoft 365 to recognize contributions

Published Jul 29 2021 10:51 AM 1,496 Views

So, recognition is important, and it is important to keep in mind that not everything should be automated. But a bit of gamification is a nice way to show people how they interact with different services. When considering this approach, the first step is to determine what we require. 

What data is available? 

Office 365 provides a whole lot of data you can use. You can choose to get all actions yourself or using existing reports that are available. Most of those reports can also be retrieved by the CLI for Microsoft 365. You can use the Microsoft Docs to read what activity reports are available.

 

Querying these reports using the CLI is done using a pattern: 

  • m365 to execute the cli
  • service to pass the get the report for
  • report to identify the group 
  • report type to identify what type of data is returned by the cli. 

You can query services like SharePoint using spo or teams. And there are different report types available depending on the type of data you require. 

 

 

m365 spo report activityuserdetail
m365 teams report activeuserdetail 

 

 

The activityuserdetail provides insights into what each user is doing. The activeuserdetail returns the amount of active users. For insights into who is doing what the activityuserdetail provides the most value. Using additional parameters you can specify the timeframe to get reporting for. You can read all about all options on the CLI for Microsoft 365 documentation.

 

In our case we want to post the weekly progress and thus retrieve a weeks worth of data. And since we are going to work with the data the output is going to be JSON. Resulting in the following snippet: 

 

 

m365 teams report useractivityuserdetail --period D7 --output json

 

 

Working with the result set

The data returned contains a bit of information we do not require and is not quite the format that we need to do reporting on. To remediate that we will use JMESPath to sort and filter the returned data. This ensures that we get only the information we need. 

 

The data returned is ordered by the user display name, so the first step is to order by a metric we care about. The data returned contains four metrics we can use.

  1. Team Chat Message Count
  2. Private Chat message Count
  3. Call Count
  4. Meeting Count

For this demo we will use the Team Chat Message count, but you can pick any option you like. Using JMESPath we can use the sort_by() functionality. Add a reverse() to make sure it is sorted with the highest number on top.  And since we only care about the User itself and do not need other information we can tell JMESPath to only return the User Principal Name. We can even specify that we care only about the top 3 users. So the full query would look as follows. 

 

 

m365 teams report useractivityuserdetail --period D7 --output json --query 'reverse(sort_by(@, &\"Team Chat Message Count\")) | [0:3].\"User Principal Name\"'

 

 

Given that there are other services as well we might use different options to order by for different services. For SharePoint you could use the Viewed or Edited File Count, Visited Page Count, the Shared Internally File Count or the Shared Externally File count. And services like Yammer offer a Posted Count, Read Count and Liked Count. 

 

 

m365 spo report activityuserdetail --period D7 --output json --query 'reverse(sort_by(@, &\"Viewed Or Edited File Count\")) | [0:3].\"User Principal Name\"'
m365 yammer report activityuserdetail --period D7 --output json --query 'reverse(sort_by(@, &\"Posted Count\")) | [0:3].\"User Principal Name\"'

 

 

 Presenting your results

With the commands above we can retrieve the information we need to identify the social champions of last week. The next challenge is to present this information. On the techcommunity there is a great walkthrough on How to send Adaptive Cards with CLI Microsoft 365. It explains into detail how to create a new webhook in teams and use the CLI to send information to this webhook.  If you follow that walkthrough and perhaps set a fancy logo you will end up with the URL you need and a welcome post that looks something like the following: 

social-webhook.png

Sharing your data

Once the webhook is set up you can use the URL and post results to it. Since we already have the data present we can use PowerShell to set the JSON of the card, add our users to it and post the card to Teams. Make sure to add some emojis to the Adaptive card to make it look pretty 🦾 or tweak it to your own liking. 

 

 

 

$m365Status = m365 status

if ($m365Status -eq "Logged Out") {
  # Connection to Microsoft 365
  m365 login
}

$webhookUrl = "<PUTYOURURLHERE>"

# Send top 3 for SharePoint based on file actions.
$activityUsers = m365 spo report activityuserdetail --period D7 --output json --query 'reverse(sort_by(@, &\"Viewed Or Edited File Count\")) | [0:3].\"User Principal Name\"' | ConvertFrom-Json
$title = " SharePoint Weekly Social Champions "
$card = '{ \"type\": \"AdaptiveCard\", \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\", \"version\": \"1.2\", \"body\": [  {  \"type\": \"TextBlock\",  \"text\": \"'+$($title)+'\",  \"wrap\": true,  \"size\": \"Medium\",  \"weight\": \"Bolder\",  \"color\": \"Attention\"  },  {  \"type\": \"TextBlock\",  \"wrap\": true,  \"text\": \"Week '+$(get-date -UFormat %V)+'\",  \"fontType\": \"Default\",  \"size\": \"Small\",  \"weight\": \"Lighter\",  \"isSubtle\": true  },  {  \"type\": \"FactSet\",  \"facts\": [   {   \"title\": \"First place\",   \"value\": \"'+$($activityUsers[0])+'\"   },   {   \"title\": \"Second place\",   \"value\": \"'+$($activityUsers[1])+'\"   },   {   \"title\": \"Third place\",   \"value\": \"'+$($activityUsers[2])+'\"   }  ]  } ] }'
m365 adaptivecard send --url $webhookUrl --card $card

 

 

 

Executed the result will look as follows:  

 

2021-07-29_17-51-58.png

 

You can find this sample, and many more samples at the CLI for Microsoft Sample script repository! If you want additional reports the script would look almost the same. The main difference is the service to call, and the query to sort the results on. You can use the same approach to see who is active on Teams or Yammer. Or who is working a lot on OneDrive or Exchange if you like. 

 

 

# Send top 3 for Teams based on chat messages
$activityUsers = m365 teams report useractivityuserdetail --period D7 --output json --query 'reverse(sort_by(@, &\"Team Chat Message Count\")) | [0:3].\"User Principal Name\"' | ConvertFrom-Json
$title = " Teams Weekly Social Champions "
$card = '{ \"type\": \"AdaptiveCard\", \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\", \"version\": \"1.2\", \"body\": [  {  \"type\": \"TextBlock\",  \"text\": \"'+$($title)+'\",  \"wrap\": true,  \"size\": \"Medium\",  \"weight\": \"Bolder\",  \"color\": \"Attention\"  },  {  \"type\": \"TextBlock\",  \"wrap\": true,  \"text\": \"Week '+$(get-date -UFormat %V)+'\",  \"fontType\": \"Default\",  \"size\": \"Small\",  \"weight\": \"Lighter\",  \"isSubtle\": true  },  {  \"type\": \"FactSet\",  \"facts\": [   {   \"title\": \"First place\",   \"value\": \"'+$($activityUsers[0])+'\"   },   {   \"title\": \"Second place\",   \"value\": \"'+$($activityUsers[1])+'\"   },   {   \"title\": \"Third place\",   \"value\": \"'+$($activityUsers[2])+'\"   }  ]  } ] }'
m365 adaptivecard send --url $webhookUrl --card $card

# Send top 3 for Yammer based on posts
$activityUsers = m365 yammer report activityuserdetail --period D7 --output json --query 'reverse(sort_by(@, &\"Posted Count\")) | [0:3].\"User Principal Name\"' | ConvertFrom-Json
$title = " Yammer Weekly Social Champions "
$card = '{ \"type\": \"AdaptiveCard\", \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\", \"version\": \"1.2\", \"body\": [  {  \"type\": \"TextBlock\",  \"text\": \"'+$($title)+'\",  \"wrap\": true,  \"size\": \"Medium\",  \"weight\": \"Bolder\",  \"color\": \"Attention\"  },  {  \"type\": \"TextBlock\",  \"wrap\": true,  \"text\": \"Week '+$(get-date -UFormat %V)+'\",  \"fontType\": \"Default\",  \"size\": \"Small\",  \"weight\": \"Lighter\",  \"isSubtle\": true  },  {  \"type\": \"FactSet\",  \"facts\": [   {   \"title\": \"First place\",   \"value\": \"'+$($activityUsers[0])+'\"   },   {   \"title\": \"Second place\",   \"value\": \"'+$($activityUsers[1])+'\"   },   {   \"title\": \"Third place\",   \"value\": \"'+$($activityUsers[2])+'\"   }  ]  } ] }'
m365 adaptivecard send --url $webhookUrl --card $card

 

 

 

What's next

With that I hope that this blog provided some insights in how you can recognize your users based on their activity. Keep in mind that just automating something is not the only way to recognize contributions, but it is a fun way to see who is doing what. It might even be a great conversation starter. Or you could use the same approach to identify who is missing out and instead of sharing that publicly let a Teams Champion know who might need additional assistance. If you have any questions regarding the CLI for Microsoft or have feedback let us know! We are always looking for contributions or new sample script ideas

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2595191%22%20slang%3D%22en-US%22%3EUse%20CLI%20for%20Microsoft%20365%20to%20recognize%20contributions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2595191%22%20slang%3D%22en-US%22%3E%3CP%3ESo%2C%20recognition%20is%20important%2C%20and%20it%20is%20important%20to%20keep%20in%20mind%20that%20not%20everything%20should%20be%20automated.%20But%20a%20bit%20of%20gamification%20is%20a%20nice%20way%20to%20show%20people%20how%20they%20interact%20with%20different%20services.%20When%20considering%20this%20approach%2C%20the%20first%20step%20is%20to%20determine%20what%20we%20require.%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--385813878%22%20id%3D%22toc-hId--385813878%22%3EWhat%20data%20is%20available%3F%26nbsp%3B%3C%2FH2%3E%0A%3CP%3EOffice%20365%20provides%20a%20whole%20lot%20of%20data%20you%20can%20use.%20You%20can%20choose%20to%20get%20all%20actions%20yourself%20or%20using%20existing%20reports%20that%20are%20available.%20Most%20of%20those%20reports%20can%20also%20be%20retrieved%20by%20the%20CLI%20for%20Microsoft%20365.%20You%20can%20use%20the%20%3CA%20title%3D%22Microsoft%20Docs%20to%20read%20what%20activity%20reports%20are%20available%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fadmin%2Factivity-reports%2Factivity-reports%3Fview%3Do365-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Docs%20to%20read%20what%20activity%20reports%20are%20available%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EQuerying%20these%20reports%20using%20the%20CLI%20is%20done%20using%20a%20pattern%3A%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3Em365%3C%2FEM%3E%20to%20execute%20the%20cli%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Eservice%3C%2FEM%3E%20to%20pass%20the%20get%20the%20report%20for%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Ereport%3C%2FEM%3E%20to%20identify%20the%20group%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Ereport%20type%3C%2FEM%3E%20to%20identify%20what%20type%20of%20data%20is%20returned%20by%20the%20cli.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EYou%20can%20query%20services%20like%20SharePoint%20using%20%3CEM%3Espo%26nbsp%3B%3C%2FEM%3Eor%20%3CEM%3Eteams.%26nbsp%3B%3C%2FEM%3EAnd%20there%20are%20different%20report%20types%20available%20depending%20on%20the%20type%20of%20data%20you%20require.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20spo%20report%20activityuserdetail%0Am365%20teams%20report%20activeuserdetail%20%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CEM%3Eactivityuserdetail%3C%2FEM%3E%20provides%20insights%20into%20what%20each%20user%20is%20doing.%20The%20%3CEM%3Eactiveuserdetail%20%3C%2FEM%3Ereturns%20the%20amount%20of%20active%20users.%20For%20insights%20into%20who%20is%20doing%20what%20the%20%3CEM%3Eactivityuserdetail%3C%2FEM%3E%20provides%20the%20most%20value.%20Using%20additional%20parameters%20you%20can%20specify%20the%20timeframe%20to%20get%20reporting%20for.%20You%20can%20read%20all%20about%20all%20options%20on%20the%20%3CA%20title%3D%22CLI%20for%20Microsoft%20365%20documentation%22%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Ftenant%2Freport%2Freport-activeusercounts%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ECLI%20for%20Microsoft%20365%20documentation%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20our%20case%20we%20want%20to%20post%20the%20weekly%20progress%20and%20thus%20retrieve%20a%20weeks%20worth%20of%20data.%20And%20since%20we%20are%20going%20to%20work%20with%20the%20data%20the%20output%20is%20going%20to%20be%20JSON.%20Resulting%20in%20the%20following%20snippet%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20teams%20report%20useractivityuserdetail%20--period%20D7%20--output%20json%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2101698955%22%20id%3D%22toc-hId-2101698955%22%3EWorking%20with%20the%20result%20set%3C%2FH2%3E%0A%3CP%3EThe%20data%20returned%20contains%20a%20bit%20of%20information%20we%20do%20not%20require%20and%20is%20not%20quite%20the%20format%20that%20we%20need%20to%20do%20reporting%20on.%20To%20remediate%20that%20we%20will%20use%20JMESPath%20to%20sort%20and%20filter%20the%20returned%20data.%20This%20ensures%20that%20we%20get%20only%20the%20information%20we%20need.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20data%20returned%20is%20ordered%20by%20the%20user%20display%20name%2C%20so%20the%20first%20step%20is%20to%20order%20by%20a%20metric%20we%20care%20about.%20The%20data%20returned%20contains%20four%20metrics%20we%20can%20use.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ETeam%20Chat%20Message%20Count%3C%2FLI%3E%0A%3CLI%3EPrivate%20Chat%20message%20Count%3C%2FLI%3E%0A%3CLI%3ECall%20Count%3C%2FLI%3E%0A%3CLI%3EMeeting%20Count%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EFor%20this%20demo%20we%20will%20use%20the%20Team%20Chat%20Message%20count%2C%20but%20you%20can%20pick%20any%20option%20you%20like.%20Using%20JMESPath%20we%20can%20use%20the%20%3CEM%3Esort_by()%26nbsp%3B%3C%2FEM%3Efunctionality.%20Add%20a%20%3CEM%3Ereverse()%20%3C%2FEM%3Eto%20make%20sure%20it%20is%20sorted%20with%20the%20highest%20number%20on%20top.%26nbsp%3B%20And%20since%20we%20only%20care%20about%20the%20User%20itself%20and%20do%20not%20need%20other%20information%20we%20can%20tell%20JMESPath%20to%20only%20return%20the%26nbsp%3B%3CEM%3EUser%20Principal%20Name%3C%2FEM%3E.%20We%20can%20even%20specify%20that%20we%20care%20only%20about%20the%20top%203%20users.%20So%20the%20full%20query%20would%20look%20as%20follows.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20teams%20report%20useractivityuserdetail%20--period%20D7%20--output%20json%20--query%20'reverse(sort_by(%40%2C%20%26amp%3B%5C%22Team%20Chat%20Message%20Count%5C%22))%20%7C%20%5B0%3A3%5D.%5C%22User%20Principal%20Name%5C%22'%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGiven%20that%20there%20are%20other%20services%20as%20well%20we%20might%20use%20different%20options%20to%20order%20by%20for%20different%20services.%20For%20SharePoint%20you%20could%20use%20the%20%3CEM%3EViewed%20or%20Edited%20File%20Count%3C%2FEM%3E%2C%20%3CEM%3EVisited%20Page%20Count%3C%2FEM%3E%2C%20the%26nbsp%3B%3CEM%3EShared%20Internally%20File%20Count%3C%2FEM%3E%20or%20the%20%3CEM%3EShared%20Externally%20File%20count%3C%2FEM%3E.%20And%20services%20like%20Yammer%20offer%20a%20%3CEM%3EPosted%20Count%2C%20Read%20Count%3C%2FEM%3E%26nbsp%3Band%20Liked%3CEM%3E%20Count.%26nbsp%3B%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20spo%20report%20activityuserdetail%20--period%20D7%20--output%20json%20--query%20'reverse(sort_by(%40%2C%20%26amp%3B%5C%22Viewed%20Or%20Edited%20File%20Count%5C%22))%20%7C%20%5B0%3A3%5D.%5C%22User%20Principal%20Name%5C%22'%0Am365%20yammer%20report%20activityuserdetail%20--period%20D7%20--output%20json%20--query%20'reverse(sort_by(%40%2C%20%26amp%3B%5C%22Posted%20Count%5C%22))%20%7C%20%5B0%3A3%5D.%5C%22User%20Principal%20Name%5C%22'%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-294244492%22%20id%3D%22toc-hId-294244492%22%3E%26nbsp%3BPresenting%20your%20results%3C%2FH2%3E%0A%3CP%3EWith%20the%20commands%20above%20we%20can%20retrieve%20the%20information%20we%20need%20to%20identify%20the%20social%20champions%20of%20last%20week.%20The%20next%20challenge%20is%20to%20present%20this%20information.%26nbsp%3BOn%20the%20techcommunity%20there%20is%20a%20great%20walkthrough%20on%26nbsp%3B%3CA%20title%3D%22How%20to%20send%20Adaptive%20Cards%20with%20CLI%20Microsoft%20365%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-365-pnp-blog%2Fhow-to-send-adaptive-cards-with-cli-microsoft-365%2Fba-p%2F2143466%22%20target%3D%22_blank%22%3EHow%20to%20send%20Adaptive%20Cards%20with%20CLI%20Microsoft%20365%3C%2FA%3E.%20It%20explains%20into%20detail%20how%20to%20create%20a%20new%20webhook%20in%20teams%20and%20use%20the%20CLI%20to%20send%20information%20to%20this%20webhook.%26nbsp%3B%20If%20you%20follow%20that%20walkthrough%20and%20perhaps%20set%20a%20fancy%20logo%20you%20will%20end%20up%20with%20the%20URL%20you%20need%20and%20a%20welcome%20post%20that%20looks%20something%20like%20the%20following%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22social-webhook.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299219iA1191C410B1AE7EF%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22social-webhook.png%22%20alt%3D%22social-webhook.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1513209971%22%20id%3D%22toc-hId--1513209971%22%3ESharing%20your%20data%3C%2FH2%3E%0A%3CP%3EOnce%20the%20webhook%20is%20set%20up%20you%20can%20use%20the%20URL%20and%20post%20results%20to%20it.%20Since%20we%20already%20have%20the%20data%20present%20we%20can%20use%20PowerShell%20to%20set%20the%20JSON%20of%20the%20card%2C%20add%20our%20users%20to%20it%20and%20post%20the%20card%20to%20Teams.%20Make%20sure%20to%20add%20some%20emojis%20to%20the%20Adaptive%20card%20to%20make%20it%20look%20pretty%20%F0%9F%A6%BE%20or%20tweak%20it%20to%20your%20own%20liking.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%24m365Status%20%3D%20m365%20status%0A%0Aif%20(%24m365Status%20-eq%20%22Logged%20Out%22)%20%7B%0A%20%20%23%20Connection%20to%20Microsoft%20365%0A%20%20m365%20login%0A%7D%0A%0A%24webhookUrl%20%3D%20%22%3CPUTYOURURLHERE%3E%22%0A%0A%23%20Send%20top%203%20for%20SharePoint%20based%20on%20file%20actions.%0A%24activityUsers%20%3D%20m365%20spo%20report%20activityuserdetail%20--period%20D7%20--output%20json%20--query%20'reverse(sort_by(%40%2C%20%26amp%3B%5C%22Viewed%20Or%20Edited%20File%20Count%5C%22))%20%7C%20%5B0%3A3%5D.%5C%22User%20Principal%20Name%5C%22'%20%7C%20ConvertFrom-Json%0A%24title%20%3D%20%22%20SharePoint%20Weekly%20Social%20Champions%20%22%0A%24card%20%3D%20'%7B%20%5C%22type%5C%22%3A%20%5C%22AdaptiveCard%5C%22%2C%20%5C%22%24schema%5C%22%3A%20%5C%22http%3A%2F%2Fadaptivecards.io%2Fschemas%2Fadaptive-card.json%5C%22%2C%20%5C%22version%5C%22%3A%20%5C%221.2%5C%22%2C%20%5C%22body%5C%22%3A%20%5B%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22TextBlock%5C%22%2C%20%20%5C%22text%5C%22%3A%20%5C%22'%2B%24(%24title)%2B'%5C%22%2C%20%20%5C%22wrap%5C%22%3A%20true%2C%20%20%5C%22size%5C%22%3A%20%5C%22Medium%5C%22%2C%20%20%5C%22weight%5C%22%3A%20%5C%22Bolder%5C%22%2C%20%20%5C%22color%5C%22%3A%20%5C%22Attention%5C%22%20%20%7D%2C%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22TextBlock%5C%22%2C%20%20%5C%22wrap%5C%22%3A%20true%2C%20%20%5C%22text%5C%22%3A%20%5C%22Week%20'%2B%24(get-date%20-UFormat%20%25V)%2B'%5C%22%2C%20%20%5C%22fontType%5C%22%3A%20%5C%22Default%5C%22%2C%20%20%5C%22size%5C%22%3A%20%5C%22Small%5C%22%2C%20%20%5C%22weight%5C%22%3A%20%5C%22Lighter%5C%22%2C%20%20%5C%22isSubtle%5C%22%3A%20true%20%20%7D%2C%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22FactSet%5C%22%2C%20%20%5C%22facts%5C%22%3A%20%5B%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22First%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B0%5D)%2B'%5C%22%20%20%20%7D%2C%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22Second%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B1%5D)%2B'%5C%22%20%20%20%7D%2C%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22Third%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B2%5D)%2B'%5C%22%20%20%20%7D%20%20%5D%20%20%7D%20%5D%20%7D'%0Am365%20adaptivecard%20send%20--url%20%24webhookUrl%20--card%20%24card%3C%2FPUTYOURURLHERE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExecuted%20the%20result%20will%20look%20as%20follows%3A%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222021-07-29_17-51-58.png%22%20style%3D%22width%3A%20978px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299220i27CF4CD57EEA3ED7%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222021-07-29_17-51-58.png%22%20alt%3D%222021-07-29_17-51-58.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20find%20this%20sample%2C%20and%20many%20more%20samples%20at%20the%20%3CA%20title%3D%22CLI%20for%20Microsoft%20Sample%20script%20repository%22%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECLI%20for%20Microsoft%20Sample%20script%20repository%3C%2FA%3E!%20If%20you%20want%20additional%20reports%20the%20script%20would%20look%20almost%20the%20same.%20The%20main%20difference%20is%20the%20service%20to%20call%2C%20and%20the%20query%20to%20sort%20the%20results%20on.%20You%20can%20use%20the%20same%20approach%20to%20see%20who%20is%20active%20on%20Teams%20or%20Yammer.%20Or%20who%20is%20working%20a%20lot%20on%20OneDrive%20or%20Exchange%20if%20you%20like.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%23%20Send%20top%203%20for%20Teams%20based%20on%20chat%20messages%0A%24activityUsers%20%3D%20m365%20teams%20report%20useractivityuserdetail%20--period%20D7%20--output%20json%20--query%20'reverse(sort_by(%40%2C%20%26amp%3B%5C%22Team%20Chat%20Message%20Count%5C%22))%20%7C%20%5B0%3A3%5D.%5C%22User%20Principal%20Name%5C%22'%20%7C%20ConvertFrom-Json%0A%24title%20%3D%20%22%20Teams%20Weekly%20Social%20Champions%20%22%0A%24card%20%3D%20'%7B%20%5C%22type%5C%22%3A%20%5C%22AdaptiveCard%5C%22%2C%20%5C%22%24schema%5C%22%3A%20%5C%22http%3A%2F%2Fadaptivecards.io%2Fschemas%2Fadaptive-card.json%5C%22%2C%20%5C%22version%5C%22%3A%20%5C%221.2%5C%22%2C%20%5C%22body%5C%22%3A%20%5B%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22TextBlock%5C%22%2C%20%20%5C%22text%5C%22%3A%20%5C%22'%2B%24(%24title)%2B'%5C%22%2C%20%20%5C%22wrap%5C%22%3A%20true%2C%20%20%5C%22size%5C%22%3A%20%5C%22Medium%5C%22%2C%20%20%5C%22weight%5C%22%3A%20%5C%22Bolder%5C%22%2C%20%20%5C%22color%5C%22%3A%20%5C%22Attention%5C%22%20%20%7D%2C%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22TextBlock%5C%22%2C%20%20%5C%22wrap%5C%22%3A%20true%2C%20%20%5C%22text%5C%22%3A%20%5C%22Week%20'%2B%24(get-date%20-UFormat%20%25V)%2B'%5C%22%2C%20%20%5C%22fontType%5C%22%3A%20%5C%22Default%5C%22%2C%20%20%5C%22size%5C%22%3A%20%5C%22Small%5C%22%2C%20%20%5C%22weight%5C%22%3A%20%5C%22Lighter%5C%22%2C%20%20%5C%22isSubtle%5C%22%3A%20true%20%20%7D%2C%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22FactSet%5C%22%2C%20%20%5C%22facts%5C%22%3A%20%5B%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22First%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B0%5D)%2B'%5C%22%20%20%20%7D%2C%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22Second%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B1%5D)%2B'%5C%22%20%20%20%7D%2C%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22Third%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B2%5D)%2B'%5C%22%20%20%20%7D%20%20%5D%20%20%7D%20%5D%20%7D'%0Am365%20adaptivecard%20send%20--url%20%24webhookUrl%20--card%20%24card%0A%0A%23%20Send%20top%203%20for%20Yammer%20based%20on%20posts%0A%24activityUsers%20%3D%20m365%20yammer%20report%20activityuserdetail%20--period%20D7%20--output%20json%20--query%20'reverse(sort_by(%40%2C%20%26amp%3B%5C%22Posted%20Count%5C%22))%20%7C%20%5B0%3A3%5D.%5C%22User%20Principal%20Name%5C%22'%20%7C%20ConvertFrom-Json%0A%24title%20%3D%20%22%20Yammer%20Weekly%20Social%20Champions%20%22%0A%24card%20%3D%20'%7B%20%5C%22type%5C%22%3A%20%5C%22AdaptiveCard%5C%22%2C%20%5C%22%24schema%5C%22%3A%20%5C%22http%3A%2F%2Fadaptivecards.io%2Fschemas%2Fadaptive-card.json%5C%22%2C%20%5C%22version%5C%22%3A%20%5C%221.2%5C%22%2C%20%5C%22body%5C%22%3A%20%5B%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22TextBlock%5C%22%2C%20%20%5C%22text%5C%22%3A%20%5C%22'%2B%24(%24title)%2B'%5C%22%2C%20%20%5C%22wrap%5C%22%3A%20true%2C%20%20%5C%22size%5C%22%3A%20%5C%22Medium%5C%22%2C%20%20%5C%22weight%5C%22%3A%20%5C%22Bolder%5C%22%2C%20%20%5C%22color%5C%22%3A%20%5C%22Attention%5C%22%20%20%7D%2C%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22TextBlock%5C%22%2C%20%20%5C%22wrap%5C%22%3A%20true%2C%20%20%5C%22text%5C%22%3A%20%5C%22Week%20'%2B%24(get-date%20-UFormat%20%25V)%2B'%5C%22%2C%20%20%5C%22fontType%5C%22%3A%20%5C%22Default%5C%22%2C%20%20%5C%22size%5C%22%3A%20%5C%22Small%5C%22%2C%20%20%5C%22weight%5C%22%3A%20%5C%22Lighter%5C%22%2C%20%20%5C%22isSubtle%5C%22%3A%20true%20%20%7D%2C%20%20%7B%20%20%5C%22type%5C%22%3A%20%5C%22FactSet%5C%22%2C%20%20%5C%22facts%5C%22%3A%20%5B%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22First%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B0%5D)%2B'%5C%22%20%20%20%7D%2C%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22Second%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B1%5D)%2B'%5C%22%20%20%20%7D%2C%20%20%20%7B%20%20%20%5C%22title%5C%22%3A%20%5C%22Third%20place%5C%22%2C%20%20%20%5C%22value%5C%22%3A%20%5C%22'%2B%24(%24activityUsers%5B2%5D)%2B'%5C%22%20%20%20%7D%20%20%5D%20%20%7D%20%5D%20%7D'%0Am365%20adaptivecard%20send%20--url%20%24webhookUrl%20--card%20%24card%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-974302862%22%20id%3D%22toc-hId-974302862%22%3EWhat's%20next%3C%2FH2%3E%0A%3CP%3E%3CSPAN%3EWith%20that%20I%20hope%20that%20this%20blog%20provided%20some%20insights%20in%20how%20you%20can%20recognize%20your%20users%26nbsp%3B%3C%2FSPAN%3Ebased%20on%20their%20activity.%20Keep%20in%20mind%20that%20just%20automating%20something%20is%20not%20the%20only%20way%20to%20recognize%20contributions%2C%20but%20it%20is%20a%20fun%20way%20to%20see%20who%20is%20doing%20what.%20It%20might%20even%20be%20a%20great%20conversation%20starter.%20Or%20you%20could%20use%20the%20same%20approach%20to%20identify%20who%20is%20missing%20out%20and%20instead%20of%20sharing%20that%20publicly%20let%20a%20Teams%20Champion%20know%20who%20might%20need%20additional%20assistance.%20If%20you%20have%20any%20questions%20regarding%20the%20CLI%20for%20Microsoft%20or%20have%20feedback%20let%20us%20know!%20We%20are%20always%20looking%20for%20%3CA%20title%3D%22contributions%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fpnp%2Fcli-microsoft365%2Fissues%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Econtributions%3C%2FA%3E%20or%20new%20%3CA%20title%3D%22CLI%20for%20Microsoft%20365%20sample%20script%20ideas%22%20href%3D%22https%3A%2F%2Faka.ms%2Fcli-m365%2Fnew-sample-script%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Esample%20script%20ideas%3C%2FA%3E!%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2595191%22%20slang%3D%22en-US%22%3E%3CP%3EAdoption%20is%20an%20important%20step%20in%20any%20project.%20And%20a%20great%20way%20to%20drive%20adoption%20is%20to%20identify%20your%20champions%20and%20recognize%20their%20contributions.%20When%20reading%20%3CA%20title%3D%22SharePoint%20Better%20Practices%3A%20Identifying%20Your%20Microsoft%20365%20Champions%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fcommunity%2Fidentifying-your-sharepoint-champions%23in-training-sessions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESharePoint%20Better%20Practices%3A%20Identifying%20Your%20Microsoft%20365%20Champions%3C%2FA%3E%26nbsp%3Bit%20got%20me%20thinking%20on%20how%20to%20achieve%20some%20form%20of%20automation%20and%20recognize%20the%20contributions%20across%20different%20teams.%20As%20it%20turns%20out%20you%20can%20use%20the%20CLI%20for%20Microsoft%20to%20automate%20a%20great%20deal%20of%20that%20job%20and%20use%20insights%20already%20present%20to%20post%20about%20top%20contributors.%20This%20blog%20is%20a%20write%20up%20on%20how%20you%20can%20post%20your%20weekly%20top%20contributors%20to%20Teams%20using%20the%20CLI%20for%20Microsoft%20365.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222021-07-29_19-44-44.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299244iB1C0691A1C49F9C7%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222021-07-29_19-44-44.png%22%20alt%3D%222021-07-29_19-44-44.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎Jul 29 2021 10:47 AM
Updated by:
www.000webhost.com