Skip to content

Get-MsOGroups-Html

MSOnline: HTML report of Azure AD groups

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [switch]$IsAgentRole,
    [switch]$HasLicenseErrorsOnly,
    [switch]$HasErrorsOnly,
    [ValidateSet('All','Security','MailEnabledSecurity','DistributionList')]
    [string]$GroupType = 'All',
    [guid]$TenantId
)

Process {
    try {
        [hashtable]$getArgs = @{'ErrorAction' = 'Stop'; 'TenantId' = $TenantId}
        if ($IsAgentRole) { $getArgs.Add('IsAgentRole', $true) }
        if ($HasLicenseErrorsOnly) { $getArgs.Add('HasLicenseErrorsOnly', $true) }
        if ($HasErrorsOnly) { $getArgs.Add('HasErrorsOnly', $true) }

        $result = Get-MsolGroup @getArgs -GroupType $GroupType | Select-Object DisplayName, EmailAddress, ObjectId, GroupType
        if ($null -eq $result -or $result.Count -eq 0) { Write-Output "No groups found"; return }
        Write-Output ($result | ConvertTo-Html -Fragment)
    }
    catch { throw }
}
Off

Only agent groups

Off

Only security groups with license errors

Off

Only groups with validation errors

Type of groups to retrieve

Unique ID of the tenant

An interactive directory of PowerShell scripts.