Skip to content

Remove-MSTTeam

Teams: Deletes a Team from Microsoft Teams

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$GroupId
)

Process {
    try {
        $teamInfo = Get-Team -GroupId $GroupId -ErrorAction Stop | Select-Object DisplayName
        $null = Remove-Team -GroupId $GroupId -ErrorAction Stop

        [PSCustomObject]@{
            Timestamp   = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
            GroupId     = $GroupId
            DisplayName = $teamInfo.DisplayName
            Status      = "Team '$($teamInfo.DisplayName)' successfully removed"
        }
    }
    catch { throw }
}

GroupId of the team

An interactive directory of PowerShell scripts.