Last active
July 6, 2023 13:00
-
-
Save guillaumemeyer/4a3e2788ba0d3d06a7cf273140cc0a73 to your computer and use it in GitHub Desktop.
Exports the participants of a Microsoft Teams meeting as a CSV file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ****************************************************************************************************************************** | |
// Abstract: | |
// This script is just a quick hack to export the participants of a team meeting as a CSV file without administrator permissions. | |
// | |
// Usage: | |
// 1. Open your meeting | |
// 2. Click on the participants list to open the popover | |
// 3. Open your browser console | |
// 4. Copy and paste all the content of this script to the console and type "Enter" | |
// 5. The CSV file download should start automatically | |
// ****************************************************************************************************************************** | |
$(function() { | |
// ************** | |
// Initialization | |
// ************** | |
const csvFileName = 'team-meeting-participants-export.csv' | |
const csvDelimiter = ',' | |
const csvHeader = 'Display Name' + csvDelimiter + 'UPN' + '\r\n' // CSV header row | |
let csvContent = csvHeader // Initialize CSV content | |
const participantsLength = $('.participant-title').length // Number of visible participants | |
// ***************************** | |
// Iterate over each participant | |
// ***************************** | |
for (let index = 0; index < participantsLength; index++) { | |
// Extract the display name (trimming extra spaces and line breaks) | |
const displayName = $('.participant-title').eq(index).text().replace(/\s+/g,' ').trim().replace(/\n/g, " ") | |
// Extract upn | |
const upn = $('.popover-content .person-profile img').eq(index).attr('upn') | |
// Append to the CSV content | |
const csvRow = displayName + csvDelimiter + upn + '\r\n' | |
csvContent += csvRow | |
} | |
// Debug the export to console | |
console.info(participantsLength + ' participants exported:') | |
console.info(csvContent) | |
// ********************************************************** | |
// Dynamically generates a CSV file and triggers its download | |
// ********************************************************** | |
// Create a dynamic "a" tag | |
var element = document.createElement('a') | |
// Set href link with content | |
element.setAttribute( | |
'href', | |
'data:application/json;charset=utf-8,' + encodeURIComponent(csvContent) | |
) | |
// Set downloaded file name | |
element.setAttribute('download', csvFileName) | |
// Hide the elemement and add it to the page | |
element.style.display = 'none' | |
document.body.appendChild(element) | |
// Launch download | |
element.click() | |
// Remove element | |
document.body.removeChild(element) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment