Skip to content

Set-MgmtGraphTeam

MgmtGraph: Updates Microsoft Team properties

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Teams

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity,

    [string]$DisplayName,

    [string]$Description,

    [ValidateSet('Public', 'Private')]
    [string]$Visibility
)

Process {
    try {
        $params = @{
            'TeamId'      = $Identity
            'Confirm'     = $false
            'ErrorAction' = 'Stop'
        }

        if ($PSBoundParameters.ContainsKey('DisplayName')) { $params.Add('DisplayName', $DisplayName) }
        if ($PSBoundParameters.ContainsKey('Description')) { $params.Add('Description', $Description) }
        if ($PSBoundParameters.ContainsKey('Visibility')) { $params.Add('Visibility', $Visibility) }

        if ($params.Count -gt 3) {
            Update-MgTeam @params
            
            $result = [PSCustomObject]@{
                TeamId    = $Identity
                Action    = "TeamUpdated"
                Status    = "Success"
                Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
            Write-Output $result
        }
        else {
            Write-Warning "No properties specified to update for Team."
        }
    }
    catch {
        throw
    }
}

Specifies the ID of the Team to update.

Optional. Specifies the new display name for the Team.

Optional. Specifies the new description for the Team.

Optional. Specifies the new visibility level. Valid values: Public, Private.

An interactive directory of PowerShell scripts.