Microsoft Teams. Thêm đồng thời nhiều member vào team

Microsoft Teams. Thêm đồng thời nhiều member vào team

Phần 1. Chuẩn bị máy

1. Chạy PowerShell với quyền quản trị

2. Thực thi câu lệnh Install-Module -Name MicrosoftTeams. Nhiều khả năng là sẽ được yêu cầu cài đặt NuGet. Chấp thuận cài đặt NuGet để tiếp tục.

3. Đóng cửa sổ PowerShell

4. Chạy PowerShell với quyền người dùng bình thường.

5. Thực thi lần lượt các câu lệnh:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
Import-Module MicrosoftTeams
Connect-MicrosoftTeams

6. Tạo script để thêm member (dùng trình soạn thảo bất kỳ). Tạm gọi tên script là "mst-bulkuseradd.ps1". Nội dung như sau:

Write-Host "Starting the script..."

$FILE_LOCATION = Read-Host -Prompt 'Enter the path to the emails csv file'
$GROUP_ID = Read-Host -Prompt 'Input Group ID'
$USER_TYPE = Read-Host -Prompt 'User Type(Owner/Member)'
$USER_EMAILS = Import-Csv -Path "$FILE_LOCATION"

foreach ($email in $USER_EMAILS) {
Write-Host ("Adding " + $email.email)
Add-TeamUser -GroupId $GROUP_ID -user $email.email -role $USER_TYPE
}

Write-Host "--------------------------------------------------------------"
Write-Host "Users added to the team successfully !"
Write-Host "--------------------------------------------------------------"
CMD /c PAUSE

Phần 2. Thêm loạt member vào team

1. Tạo file CSV chứa địa chỉ email của các member (sử dụng trình soạn thảo bất kỳ) Tạm gọi tên file là "members.csv". Nội dung có dạng như sau:

email
abc@test.com
cde@test.com
fgh@test.com

Lưu ý, dòng đầu tiên bắt buộc phải là chữ "email"; các dòng sau lần lượt là email của các member cần được thêm vào team. 

2. Lấy GroupId của team. Cách đơn giản để thực hiện là trong phần mềm Microsoft Teams, thực hiện chức năng "Get Link to Team". Trong link thu được sẽ có GroupID.

Ví dụ link:

https://teams.microsoft.com/l/team/19%3awklAkfuQYd0qitw2pdrSNzn7gDJCgqM3w5KFdmIkVVs1%40thread.tacv2/conversations?groupId=9ada3ce1-d753-444e-bc20-a4f70b1b2913&tenantId=0aa16d8a-a396-4e21-aa14-2a68a45786bc

Khi đó, GroupId là:

9ada3ce1-d753-444e-bc20-a4f70b1b2913

3. Trong PowerShell (đã chuẩn bị ở bước 5, Phần 1), thực thi script "mst-bulkuseradd.ps1".

4. Xong! Kiểm tra kết quả!

Tài liệu tham khảo

[1]. GihanBlog, "Add bulk users to MS Teams?", Online:  https://gihanblog.netlify.app/posts/2020-08-19/add-bulk-users-to-teams (Truy cập ngày 30/07/2021)

[2]. Chia sẻ của Tomáš_K, Online: https://answers.microsoft.com/en-us/msoffice/forum/all/connect-microsoftteams-not-working/f3235724-ec03-4a9e-9679-40afa89bf956?messageId=9001e971-77f8-4b3a-ad97-8c3c9a263b40 (Truy cập ngày 30/07/2021)

Comments

Popular posts from this blog

Cài đặt Xdebug cho VSCode trên Windows

Lập trình tạo một MVC Component đơn giản cho Joomla. Phần 4. Chỉnh sửa một phần tử

Lập trình tạo một MVC Component đơn giản cho Joomla. Phần 1. Khởi tạo component