4 Useful Scripts with Update-MgGroup in PowerShell

Managing Microsoft 365 groups often requires administrators to make updates such as changing names, modifying mail settings, or adjusting visibility. With Microsoft Graph PowerShell, the Update-MgGroup cmdlet makes these updates easy, reliable, and scriptable.

In this article, you’ll learn four practical and beginner-friendly scripts using Update-MgGroup to update different aspects of Microsoft 365 groups. Each example shows exactly how to use the cmdlet and includes simple explanations to help you understand what the script does.


Prerequisites

Before running any of the following scripts, install and connect to Microsoft Graph PowerShell:

Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Group.ReadWrite.All"

Once connected, you're ready to update your groups.


  • Update Group Display Name and Description
  • You should pass in the new display name and description along with Group ID.

    Update-MgGroup -GroupId "12345678-90ab-cdef-1234-567890abcdef" -DisplayName "New Group Name" -Description "Updated group description"

    Explanation:

    This script updates both the name and description of a Microsoft 365 group. It’s useful when a team undergoes rebranding, organizational changes, or when descriptions need clarifying.

  • Change Group Visibility to Private
  • You should pass in the new group visibility along with Group ID.

    Update-MgGroup -GroupId "12345678-90ab-cdef-1234-567890abcdef" -Visibility Private

    Explanation:

    This updates the group’s visibility to Private, meaning only approved members can view the group’s content. Perfect for confidential or internal teams.

  • Update a Group's Mail Nickname
  • To change the mail nickname (alias) of a Microsoft 365 group, execute:

    Update-MgGroup -GroupId "12345678-90ab-cdef-1234-567890abcdef" -MailNickname "NewAlias"

    Explanation:

    The mail nickname determines the email alias of the group.

    • ✔ Changing it affects the group’s email address.
    • ✔ Ensure the new alias matches your organization’s naming policy.

    This script is especially useful after renaming departments, teams, or distribution lists.

  • Enable or Disable a Group's Mail and Security Settings
  • To configure a group's mail-enabled and security-enabled settings, use:

    Update-MgGroup -GroupId "12345678-90ab-cdef-1234-567890abcdef" -MailEnabled $true -SecurityEnabled $false

    Explanation:

    This script turns the group into a mail-enabled group while disabling its security group functionality.

    Useful scenarios include:

    • Converting a security-only group into a mail-enabled distribution group
    • Adjusting group capabilities during restructuring
    • Ensuring group functionality aligns with organizational policies

Cmdlet Tips

  • You must know the group’s GroupId before performing updates.
  • Not all properties can be updated directly with parameters; some require the -BodyParameter option.
  • Always verify the changes using:
  • Get-MgGroup -GroupId <ID>
  • Changing a mail nickname permanently affects the group’s email address.
  • Visibility changes affect access, so use them carefully.

Possible Errors and Solutions

Error Cause Solution
Insufficient privileges Missing permissions Use Connect-MgGraph -Scopes "Group.ReadWrite.All"
Request_BadRequest Invalid value for DisplayName, MailNickname, or Visibility Ensure values follow Microsoft 365 naming rules
Group not found Wrong GroupId Confirm with Get-MgGroup
Property is read-only Trying to update unsupported attributes Only update allowed properties

Conclusion

The Update-MgGroup cmdlet is a powerful and flexible tool for managing Microsoft 365 group attributes. Whether you’re updating names, managing visibility, changing email aliases, or configuring mail/security settings, these scripts give you a strong foundation for day-to-day group administration.

As your PowerShell automation grows, you can combine these updates into larger workflows to streamline group management across your organization.


Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex