Microsoft 365 Groups play a central role in collaboration and resource access across Microsoft 365 services. By pairing Get-MgGroup
and Update-MgGroup
, administrators can retrieve group details and update their properties efficiently. This article outlines how to use these cmdlets together, providing a practical example, tips, and troubleshooting guidance.
The Get-MgGroup
cmdlet retrieves detailed information about groups, including their display name, description, and membership type. The Update-MgGroup
cmdlet allows you to modify properties like group names, descriptions, and settings. Combining these cmdlets enables administrators to automate updates, enforce naming conventions, or standardize group configurations.
# Step 1: Retrieve the group by display name
$groupName = "Marketing Team" # Replace with the group's display name
$group = Get-MgGroup -Filter "displayName eq '$groupName'"
if ($group -ne $null) {
Write-Output "Group Found: $($group.DisplayName)"
Write-Output "Current Description: $($group.Description)"
} else {
Write-Error "Group not found."
return
}
# Step 2: Update the group's description
$updatedProperties = @{
Description = "This group is for all members of the Marketing Department."
}
Update-MgGroup -GroupId $group.Id -BodyParameter $updatedProperties
Write-Output "Group description updated successfully."
-Filter
parameter with Get-MgGroup
to retrieve specific groups based on properties like displayName:
Get-MgGroup -Filter "groupTypes/any(c:c eq 'Unified')"
Update-MgGroup
, include only the properties you want to update. Unspecified properties will remain unchanged.$groupPrefix = "Dept-"
Update-MgGroup -GroupId $group.Id -BodyParameter @{ DisplayName = "$groupPrefix$($group.DisplayName)" }
Error Message | Cause | Solution |
Group Not Found | Group name or ID does not match any existing group | Verify the group name or filter criteria. |
Access Denied | Insufficient permissions | Assign appropriate permissions like Group.ReadWrite.All . |
Property Not Supported for Update | Attempting to update a read-only property | Check the Microsoft Graph schema to confirm writable properties. |
Invalid JSON in -BodyParameter | Malformed JSON payload | Ensure the payload adheres to the correct schema and syntax. |
Pairing Get-MgGroup
and Update-MgGroup
allows administrators to manage Microsoft 365 Groups efficiently. Whether you’re standardizing group properties, automating updates, or implementing compliance policies, these cmdlets provide the flexibility and control you need.
By following best practices and leveraging the power of Microsoft Graph PowerShell, you can streamline group management workflows and enhance collaboration across your organization.
© m365corner.com. All Rights Reserved. Design by HTML Codex