Skip to content

Invoke-MgmtGraphTeamArchiveAction

MgmtGraph: Manages archive actions for a Microsoft Team

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

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

    [Parameter(Mandatory = $true)]
    [bool]$Archive
)

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

        if ($Archive) {
            Invoke-MgArchiveTeam @params
        }
        else {
            Invoke-MgUnarchiveTeam @params
        }
        
        $result = [PSCustomObject]@{
            TeamId    = $Identity
            Action    = if ($Archive) { "TeamArchived" } else { "TeamUnarchived" }
            Status    = "Success"
            Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the ID of the Team.

Specifies whether to archive ($true) or unarchive ($false) the Team.

An interactive directory of PowerShell scripts.