Skip to content

Get-MgmtGraphAllGroupSite

MgmtGraph: Retrieves all SharePoint sites associated with a group

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

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

Process {
    try {
        $sites = Get-MgAllGroupSite -GroupId $GroupId -ErrorAction Stop
        
        $results = foreach ($s in $sites) {
            [PSCustomObject]@{
                GroupId     = $GroupId
                SiteId      = $s.Id
                DisplayName = $s.DisplayName
                Name        = $s.Name
                WebUrl      = $s.WebUrl
                Timestamp   = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
            }
        }

        Write-Output $results
    }
    catch {
        throw
    }
}

The unique identifier of the Microsoft Graph group.

An interactive directory of PowerShell scripts.