Mar 15 2024 08:46 AM
Teams was updated fairly recently. I was previously able to export a Member List of Teams Channel using a script. This appears to no longer be the case or is there a new way to do this?
Mar 16 2024 06:51 PM
Mar 18 2024 05:05 AM
@VasilMichev the script might be part of the issue, but there might be some others. Part of the process before was to right click in the white space to "Inspect" to input the script in "Console"; being able to right click in that empty space is no longer do-able.
Below is the script I was using:
$(function() {
// **************
// Initialization
// **************
const csvFileName = 'team-membership-roster-export.csv'
const csvDelimiter = ','
const csvHeader = 'Display Name' + csvDelimiter + 'Title' + csvDelimiter + 'Location' + csvDelimiter + 'Role' + csvDelimiter + 'UPN' + '\r\n' // CSV header row
let csvContent = csvHeader // Initialize CSV content
const rosterLength = $('.td-member-display-name').length // Number of visible members
// Check if we're an owner of the team
let roleSelector = '.td-member-role' // Consider we're not an owner by default
if ($('.td-member-editable-role').length > 0) {
roleSelector = '.td-member-editable-role' // Override if we're an owner
}
// ************************
// Iterate over each member
// ************************
for (let index = 0; index < rosterLength; index++) {
// Extract the display name, title, location and role
const displayName = $('.td-member-display-name').eq(index).text()
const title = $('.td-member-title').eq(index).text()
const location = $('.td-member-location').eq(index).text()
const role = $(roleSelector).eq(index).text()
const upn = $('.td-member-photo img').eq(index).attr('upn')
// Append to the CSV content
const csvRow = displayName + csvDelimiter + title + csvDelimiter + location + csvDelimiter + role + csvDelimiter + upn + '\r\n'
csvContent += csvRow
}
// Debug the export to console
console.info(rosterLength + ' members 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)
})
Mar 18 2024 09:41 AM