Microsoft Teams is an essential tool for collaboration in modern workplaces. Pairing Get-MgTeam
and Update-MgTeam
allows administrators to retrieve details about a Team and modify its settings programmatically. This article provides an example, tips, and use cases for leveraging these cmdlets effectively.
The Get-MgTeam
cmdlet retrieves details about a specific Microsoft Team, such as its display name, description, and settings. The Update-MgTeam
cmdlet allows administrators to modify Team properties, such as member permissions, guest access, and messaging settings. Together, these cmdlets are powerful tools for managing Teams at scale, ensuring compliance with organizational policies, and streamlining collaboration.
Here’s how to retrieve a Team’s settings and update its member permissions:
# Step 1: Retrieve the Team by display name
$teamName = "Marketing Team" # Replace with your Team's display name
$team = Get-MgTeam -Filter "displayName eq '$teamName'"
if ($team -ne $null) {
Write-Output "Team Found: $($team.DisplayName)"
Write-Output "Team ID: $($team.Id)"
} else {
Write-Error "Team not found."
return
}
# Step 2: Update member permissions for the Team
$updatedSettings = @{
MemberSettings = @{
AllowCreateUpdateChannels = $false
AllowDeleteChannels = $false
}
}
try {
Update-MgTeam -TeamId $team.Id -BodyParameter $updatedSettings
Write-Output "Team settings updated successfully."
} catch {
Write-Error "Failed to update Team settings: $_"
}
Get-MgTeam
with the -Filter
parameter to locate specific Teams by properties like displayName or description:
Get-MgTeam -Filter "displayName eq 'Finance Team'"
Update-MgTeam
, specify only the properties you want to modify. Unspecified properties remain unchanged.Update-MgTeam
:
$teams = Get-MgTeam -Filter "displayName startswith 'Project'"
foreach ($team in $teams) {
Update-MgTeam -TeamId $team.Id -BodyParameter $updatedSettings
}
Error | Cause | Solution |
Team Not Found | Team does not exist or incorrect display name | Verify the Team's existence using Get-MgTeam . |
Access Denied | Insufficient permissions | Assign TeamSettings.ReadWrite.All permissions in Azure AD. |
Invalid Property | Attempting to modify a read-only property | Check the Microsoft Teams settings schema for modifiable properties. |
Too Many Requests | API throttling due to bulk updates | Implement retries with exponential backoff. |
JSON Schema Error | Malformed JSON payload in -BodyParameter |
Ensure the JSON adheres to the required schema for Teams updates. |
Pairing Get-MgTeam
and Update-MgTeam
provides administrators with the ability to manage Teams programmatically, enhancing collaboration and ensuring compliance with organizational policies. From configuring member permissions to enforcing governance rules, these cmdlets streamline Teams management and help maintain a secure, productive environment.
By leveraging these cmdlets effectively, administrators can save time, reduce errors, and ensure Teams are configured to meet organizational needs.
© m365corner.com. All Rights Reserved. Design by HTML Codex