- Locks down group creation, but allows anyone to request a Team
- Team creation is done with approval
- Teams are created automatically after approval using PowerShell
Lock Down M365 group creation
Create a PowerShell Script
Install-Module -Name MicrosoftTeams -Force -AllowClobber
$username = "TeamsAdmin@contoso.com"
$password = ConvertTo-SecureString "TeamsAdminPassword” -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential -ArgumentList ($username, $password)
Connect-MicrosoftTeams -credential $psCred
$TeamFocus = "Department"
$TeamDept = "Accounting"
$TeamProject = "Accounts Payable"
$TeamDescription = "Description for the Team " + $TeamDept +", "+$TeamProject
$TeamVisibility = "Public" # or "Private"
$TeamOwner1 = "TeamsAdmin@contoso.com"
$TeamOwner2 = "bob@contoso.com"
$TeamOwner3 = "sara@contoso.com"
$TeamChannel1 = "Team 1"
$TeamChannel2 = "Team 2"
$TeamChannel3 = "Team 3"
if($TeamFocus -eq "Department"){
$TeamName = "Dept "+$TeamDept +" "+$TeamProject
}
elseif($TeamFocus -eq "Project"){
$TeamName = "Proj " + $TeamProject
}
else{
$TeamName = "Team " + $TeamProject
}
$TeamNickname = $TeamName -replace '(^\s+|\s+$)','' -replace '\s+','' -replace '&',''
try{$group = New-Team -DisplayName $TeamName -Description $TeamDescription -Visibility $TeamVisibility}
catch{
$rand = Get-Random -Maximum 100
$TeamNickname += $rand
$TeamName = $TeamName + " " + $rand
$group = New-Team -MailNickname $TeamNickname -DisplayName $TeamName -Description $TeamDescription -Visibility $TeamVisibility
}
finally{
Add-TeamUser -GroupId $group.GroupId -User $TeamOwner1 -Role "owner"
Add-TeamUser -GroupId $group.GroupId -User $TeamOwner2 -Role "owner"
Add-TeamUser -GroupId $group.GroupId -User $TeamOwner3 -Role "owner"
if($TeamChannel1 -ne ""){
New-TeamChannel -GroupId $group.GroupId -DisplayName $TeamChannel1
}
if($TeamChannel2 -ne ""){
New-TeamChannel -GroupId $group.GroupId -DisplayName $TeamChannel2
}
if($TeamChannel3 -ne ""){
New-TeamChannel -GroupId $group.GroupId -DisplayName $TeamChannel3
}
Disconnect-MicrosoftTeams
}
Set up approvals in your ticketing system
- Requester creates a ticket, filling in the info needed for the PowerShell variables in the ticket.
- Then the ticket goes to the requesters manager for approval
- If that is approved, then it goes to IT leadership, where at least 2 leaders must approve the request.
- If they approve it, then the above PowerShell command launches, with the variables populated by what the requester put into the ticket which creates the Team. The owner gets an automated email from Microsoft telling them that they have been added to the Team as an owner, and then the ticket closes.
If you get errors...
- https://techgenix.com/creating-a-new-team-using-powershell/
- https://docs.microsoft.com/en-us/microsoftteams/teams-powershell-managing-teams
- https://docs.microsoft.com/en-us/powershell/module/teams/new-team?view=teams-ps
- https://answers.microsoft.com/en-us/msoffice/forum/all/turning-off-email-notification-when-adding-team/ea22f6c7-20f0-4b35-97eb-bf923b353e4f
- https://docs.microsoft.com/en-us/microsoft-365/solutions/manage-creation-of-groups?view=o365-worldwide
- https://regroove.ca/stellark/2021/09/15/teams-governance-and-locking-down-teams-creation/
- https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2#msi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.