Private/Get-MMCloudDistributionGroup.ps1
function Get-MMCloudDistributionGroup { [CmdletBinding()] param ( [switch] $ExternalAllowed, # external senders are allowed [switch] $EmptyMember, [string] $CountVariable ) $null = Connect-MMExchangeOnline # Cache $exoDL= Get-EODistributionGroup -ResultSize unlimited Write-Debug $exoDL.Count #if (-not ($SyncedUser -or $SharedUser)) { $result = $exoDL #} #$dg | select -First 1 * # GroupType : Universal #$dg | Group GroupType # IsDirSynced : False #$dg | Group IsDirSynced # HiddenFromAddressListsEnabled : False #$dg | Group HiddenFromAddressListsEnabled # RequireSenderAuthenticationEnabled : True if ($ExternalAllowed) { # $dg | Group RequireSenderAuthenticationEnabled # False # Set-EODistributionGroup Falcon@contoso.OnMicrosoft.com -RequireSenderAuthenticationEnabled $false $result = $result | Where-Object {$_.RequireSenderAuthenticationEnabled -eq $false} } if ($EmptyMember) { Write-Warning "May a bit slow" $result = $result | Where-Object {$null -eq (Get-EODistributionGroupMember -Identity $_.Name)} } if ($CountVariable) { # https://learn.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.5 Set-Variable -Name $CountVariable -Value ($result.Count) -Scope 1 # 18 #Set-Variable -Name $CountVariable -Value (($result| Measure).Count) -Scope 1 # 18 #Set-Variable -Name $CountVariable -Value (@($result).Count) -Scope 1 } return $result } #$exportCount = $null #$export = Get-MMCloudDistributionGroup -CountVariable exportCount -Debug #$export.Count # 15 #$exportCount # 14 ##$export | Out-GridView #$export = Get-MMCloudDistributionGroup -ExternalAllowed ; $export| ft #$export = Get-MMCloudDistributionGroup -EmptyMember ; $export | ft |