Creating/Populating MS Teams from data

As of 28/9/2020

Some basic docs in case of unfortunate incident involving a bus.


File/Code in:


Teams.csv - Hand maintained table of: Course EUCLID Code,Team Name, Team Description,UUNs of owners (space separated),Notes (not used)

team-groupids.csv - Generated by CreateTeams.ps1 to maintain the mapping between EUCLID Code, Team Name, Internal Teams groupid. Used by PopulateTeams.ps1 to assign students to Team.

CreateTeams.ps1 - Script that given the input of Teams.csv, actually creates the Teams in MS teams, and assigns the given UUNs as owners. Generates team-groupids.csv to map between EUCLID code and MS internal team/group id.

PopulateTeams.ps1 - Does an authGET of student data from pip.inf. Goes through the list of groups in team-groupids.csv and adds the students with a matching EUCLID code to the appropriate team.

How to use


Some initial setup is required. Assuming doing this on DICE, then you need PowerShell installed:

profile.packages mEXTRA(powershell-lts-7.0.1-1.rhel.7)

Once that's available, you need to install the MicroSoft Teams module.

PS> Install-Module MicrosoftTeams -AllowPrerelease -RequiredVersion "1.1.3-preview"

Using this version as it supports some calls that other do not (yet).

Once it's installed, you don't need to do that step again.

The CreateTeams and PopulateTeams script assume you are already "connected" to Teams. Then any actions it takes it does as the person signed into Teams. To connect do:

PS> Connect-MicrosoftTeams
You'll be given a code to enter into Once you've authenticated the PowerShell prompt will return.

Now if you don't Disconnect-MicrosoftTeams or close the shell, this seems to last for days, certainly I've gone a week on a single connection.


Assuming you are running PowerShell and connected to Teams (see above), then with Teams.csv suitably populated then run

PS> ./CreateTeams.ps1

in the same directory, it will confirm the list and then create the lists and also create team-groupids.csv.

It's expected this is a "one time" thing for now. Indeed the script wont run if team-groupids.csv exists.

Whoever authenticates to the "Connect" will be an owner of the Team, along with Alex (hard coded in) and whoever is specified in the Teams.csv file.

TODO - update CreateTeams to cope with an existing teams-groupids.csv and skip/update existing teams, and add any new teams. Deletion would not be catered for.

Once the teams are created (you should see them within the Teams App), then run the PopulateTeams script

PS> ./PopulateTeams.ps1

It will do an authGET of a pip.inf URL of all the students on a course. (You may need to ask Tim to give you permission to fetch this URL).

The script will go straight into adding student UUNs to the Teams for which there is an entry in the teams-groupids.csv -> Teams.csv file. It takes a few minutes for teams with hundreds of students.

TODO - prompt for confirmation? Make adds more smart, only add new users, could also enable removal of users from teams as well. Though it wasn't thought this would be need to be scripted.


Basically works, but rough round the edges. The two scripts could certainly do with some changes to make them more useful.

Could this be completely automated? Some keytab ID to allow the authGET to run. Can we connect to a functional account straight from the PowerShell command line, rather than using the web auth?

Look at Team templates. See maths examples EDU_class?

We don't set a mailnickname for the teams. Should we?

-- NeilBrown - 28 Sep 2020

This topic: DICE > WebHome > ServicesUnit > PowerShellTeams
Topic revision: r1 - 28 Sep 2020 - 15:24:38 - NeilBrown
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
This Wiki uses Cookies