How to create a Microsoft Team and change Office 365 unified group settings using PowerShell
In this example, we will create a Team and change the Microsoft 365 group settings so that it can be used as an email distribution group without showing under "Groups" in the Outlook client.
Do you want PowerShellGet to install and import the NuGet Provider now? Yes
# Install PowerShellGet Install-Module -Name PowerShellGet -Force -AllowClobber # Install Teams PowerShell Module Install-Module -Name MicrosoftTeams -Force -AllowClobber
Do you want to change the execution policy? Yes
# Set execution policy Set-ExecutionPolicy RemoteSigned # Import Teams PowerShell module Import-Module MicrosoftTeams
# Sign into Teams online Connect-MicrosoftTeams
# create new private team New-Team -DisplayName "London Sales" -Description "London Sales Team" -Visibility Private -MailNickName LondonSales -Owner itadmin@ctrlf.cloud
| -Visibility |
Public Teams allow
all users to join the group Private Teams require an owner to approve the request to join |
| -MailNickName | Email alias for the associated Office 365 group. MailNickName will be used as the PrimarySmtpAddress |
| -Owner | The Team owner can add or remove people from the Team. If the owner is not specified, it is set to the admin user who created the Team |
# Get Team ID $Group = Get-Team -DisplayName "London Sales" | select GroupId # Add user to Team Add-TeamUser -GroupID $Group.GroupId -User bender@ctrlf.cloud
# Get Team ID $Group = Get-Team -DisplayName "London Sales" | select GroupId # Remove user from Team Remove-TeamUser -GroupID $Group.GroupId -User zoidberg@ctrlf.cloud
$Group = Get-Team -DisplayName "London Sales" | select GroupId Get-TeamUser -GroupID $Group.GroupId
Next we need to change the Microsoft 365 group settings so that it will show in the global address list and can be used as an email distribution group without showing under "Groups" in the Outlook client.
# Connect to Exchange Online PowerShell Connect-ExchangeOnline -UserPrincipalName itadmin@ctrlf.cloud
# get m365 group settings Get-UnifiedGroup -Identity "London Sales" | fl # get m365 group settings and output to file Get-UnifiedGroup -Identity "London Sales" | fl | out-file -filepath "C:\temp\london-sales-team.txt"
In this example, we will change the Microsoft 365 group settings so that it can be used as an email distribution group without showing under "Groups" in the Outlook client.
# change m365 group settings Set-UnifiedGroup -Identity "Sales" -HiddenFromAddressListsEnabled:$false -HiddenFromExchangeClientsEnabled:$true -UnifiedGroupWelcomeMessageEnabled:$false -AutoSubscribeNewMembers
|
-HiddenFromAddressListsEnabled:$false Default setting is HiddenFromAddressListsEnabled : True |
M365 group is visible in address lists |
|
-HiddenFromExchangeClientsEnabled:$true Default setting is HiddenFromExchangeClientsEnabled : True |
M365 group is hidden in Outlook client |
|
-UnifiedGroupWelcomeMessageEnabled:$false Default setting is WelcomeMessageEnabled : False | Disable sending system welcome messages to users when they are added to the group |
|
-AutoSubscribeNewMembers Default setting is AutoSubscribeNewMembers : False | Members will receive copies of team emails in their inboxes. The M365 group is used as a distribution list. |
When this option is ticked, the M365 group is used as a distribution list. This can be enabled using PowerShell Set-UnifiedGroup -AutoSubscribeNewMembers
When this option is unticked, the Team will show in the Outlook global address list. This can be configured using PowerShell Set-UnifiedGroup -HiddenFromAddressListsEnabled:$false
Microsoft 365 Group shows in the Outlook global address list
Microsoft 365 group does not show in Outlook client
This can be configured using PowerShell Set-UnifiedGroup -HiddenFromExchangeClientsEnabled:$true
References:
Install Microsoft Teams PowerShell Module
https://docs.microsoft.com/en-gb/MicrosoftTeams/teams-powershell-installMicrosoft Teams PowerShell New-Team
https://docs.microsoft.com/en-us/powershell/module/teams/new-teamExchange PowerShell Set-UnifiedGroup
by Author
https://docs.microsoft.com/en-us/powershell/module/exchange/set-unifiedgroup
Comments