Last active
September 1, 2020 02:34
-
-
Save wongcyrus/d0a4141f1a0cd0710da83b954be1f653 to your computer and use it in GitHub Desktop.
Batch imports student to Microsoft Team
This file contains 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
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
set-executionpolicy remotesigned | |
Install-Module MicrosoftTeams | |
Import-Module MicrosoftTeams | |
Disconnect-MicrosoftTeams | |
$User = "[email protected]" | |
$Password = "" | |
$ClassListFolder="C:\Users\developer\Documents\WindowsPowerShell\" | |
# ITP4104-Cloud Services-2021-2-A-cywong.csv with just one column. | |
#[email protected] | |
$PWord = ConvertTo-SecureString -String $Password -AsPlainText -Force | |
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord | |
Connect-MicrosoftTeams -Credential $Credential | |
Get-ChildItem $ClassListFolder -Filter *.csv | | |
Foreach-Object { | |
Write-Output $_.Name | |
$groupId = New-Team -DisplayName $_.FullName | |
Import-Csv -Path $studentPath | foreach{Add-TeamUser -GroupId $groupId.GroupId -User $_.email -Role Member} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment