Skip to content

Get-MgmtGraphGroupExtension

MgmtGraph: Retrieves group open extensions

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

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

    [string]$ExtensionId
)

Process {
    try {
        $params = @{
            'GroupId'     = $GroupId
            'ErrorAction' = 'Stop'
        }

        if ($ExtensionId) {
            $params.Add('ExtensionId', $ExtensionId)
        }
        else {
            $params.Add('All', $true)
        }

        $extensions = Get-MgGroupExtension @params
        
        $results = foreach ($e in $extensions) {
            [PSCustomObject]@{
                GroupId     = $GroupId
                ExtensionId = $e.Id
                Timestamp   = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
        }

        Write-Output $results
    }
    catch {
        throw
    }
}

The unique identifier of the Microsoft Graph group.

Optional. The unique identifier of a specific group extension to retrieve.

An interactive directory of PowerShell scripts.