forked from jameswh3/MW-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-Teams.ps1
More file actions
32 lines (28 loc) · 1016 Bytes
/
Copy pathNew-Teams.ps1
File metadata and controls
32 lines (28 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
param (
[Parameter(Mandatory = $true)]
[string[]]$TeamNames,
[string]$Owner,
[string[]]$Members
)
# Ensure MicrosoftTeams module is installed and imported
if (-not (Get-Module -ListAvailable -Name MicrosoftTeams)) {
Install-Module -Name MicrosoftTeams -Force -Scope CurrentUser
}
Import-Module MicrosoftTeams
# Connect to Microsoft Teams
Write-Host "Connecting to Microsoft Teams..."
#Connect-MicrosoftTeams
foreach ($teamName in $TeamNames) {
try {
Write-Host "Creating Team: $teamName"
$team = New-Team -DisplayName $teamName -Visibility Public -Owner $Owner -ErrorAction Stop
Write-Host "Team '$teamName' created with GroupId: $($team.GroupId)"
foreach ($member in $Members) {
Add-TeamUser -GroupId $team.GroupId -User $member -Role Member
Write-Host "Added member '$member' to team '$teamName'."
}
} catch {
Write-Warning "Issue creating team '$teamName': $_"
}
}
Write-Host "Team provisioning complete."