Hi,
The code below lists Microsoft 365 groups and their members. I tried to pipe the result set both for the groups and for the members using the Sort-Order parameter, but it did not result in any sorting. How can I get the groups and members sorted in this code?
Declare Variable for 365 groups
$365Groups = Get-UnifiedGroup -Identity $global:groupfilter | Sort-Object DisplayName
# Check if the group is existing
If ($365Groups) {
Foreach ($object in $365Groups) { # Loop to list all group names with member count only
$Group = Get-UnifiedGroupLinks -Identity "$object" -Linktype member | Sort-Object DisplayName
$FinalGCount = "(" + $Group.count + ")"
WriteLine $object, $FinalGCount
}
Thanks a lot for comments :-)