Skip to content
Permalink
Browse files
Teams scripts
  • Loading branch information
ac9207 committed Aug 30, 2022
1 parent 00b3b85 commit 8cec52be9f5bf07350aa7dccd55fdcc6a2c81b9f
Showing with 43 additions and 0 deletions.
  1. +13 −0 Add_Users_to_Teams.ps1
  2. +30 −0 Create_PT_Teams.ps1
@@ -0,0 +1,13 @@
# You need to have the Teams pwoershell module installed first. To do this run
# Install-Module -Name MicrosoftTeams -Scope CurrentUser
# in a powershell prompt
# The csv file must have a header and there must be a column called email
# This should have the email addesses of the people you wish to add.
# Students will be in the @uni.coventry.ac.uk format

$ea=Read-Host "Please enter your own email address"
Connect-MicrosoftTeams
Get-Team -User $ea | Format-List -Property DisplayName, GroupId
$gid=Read-Host "Please enter the group ID of the teams site you wish to add the users too"
$usercsv = Read-Host "Please enter the CSV file you wish to use to add the userd (must be in the same directory as the script)"
Import-Csv -Path $usercsv | foreach { Add-TeamUser -Verbose -Debug -GroupId $gid -User $_.email}
@@ -0,0 +1,30 @@
# You need to have the Teams pwoershell module installed first. To do this run
# Install-Module -Name MicrosoftTeams -Scope CurrentUser
# in a powershell prompt
# You'll also need to run
# Connect-MicrosoftTeams
# at the command prompt before running the script

$teams_csv="C:\Users\ac9207\OneDrive - Coventry University\Workbench\PowerShell\Master-groups.csv"
$students_csv="C:\Users\ac9207\OneDrive - Coventry University\Workbench\PowerShell\Master-students.csv"
$faye="ac9207@coventry.ac.uk"
$farzana="aa4015@coventry.ac.uk"
Import-Csv -Path $teams_csv | foreach {
$gn=$_.Group_Name
$staff=$_.Email
Write-Output $gn
Write-Output $staff
Write-Output $farzana
$group = New-Team -displayname $gn
$gid= $group.GroupId
Write-Output $gid
#Start-Sleep -s 20
#Add-TeamUser -Verbose -GroupId $group -User $faye -Role Owner
Add-TeamUser -Verbose -GroupId $gid -User $farzana -Role Owner
Add-TeamUser -Verbose -GroupId $gid -User $staff -Role Owner
Import-Csv -Path $students_csv | foreach {
$ngn=$_.PT_Teams_site
$student=$_.Email
if ($gn -eq $ngn) {Add-TeamUser -Verbose -GroupId $gid -User $student}
}
}

0 comments on commit 8cec52b

Please sign in to comment.