0 votes

Hi

Is there a method to read the amount of returned objects from Get-AdmGroupMember cmdlet (and other) ?
.Count does not work, nor does .Length.

For example:
$MembersList = Get-AdmGroupMember (whatever parameters)
$NoOfMembers = $MembersList.Count

Maybe I'm just fooling around in this modern object.hell.world ? :lol:

- Thanks

by (2.6k points)

1 Answer

0 votes
by (215k points)
selected by
Best answer

Hello,

It's because the Get-AdmGroupMember cmdlet can return different types of values depending on how many members there are in the group:

  • If the number of group members is 0, the cmdlet returns $NULL.
  • If the number of group members is 1, the cmdlet returns a single object that represents the member. The return value is of type Softerra.Adaxes.PowerShellModule.Directory.ADPrincipal.
  • If the number of group members is more than 1, the cmdlet returns an array of objects representing the members. The return value is Softerra.Adaxes.PowerShellModule.Directory.ADPrincipal[].

Here is a small sample on how to handle the return value:

Import-Module Adaxes

$MembersList = Get-AdmGroupMember -Identity "MyGroup" -AdaxesService localhost

if ($MembersList -eq $NULL)
{
    Write-Host "The group does not contain any members"
}
elseif ($MembersList -is [System.Array])
{
    Write-Host "The group contains" $MembersList.Length "members"
}
else
{
    Write-Host "The group contains 1 member"
}

Also, pay attention that the -AdaxesService parameter is mandatory when calling the cmdlet.

Related questions

0 votes
1 answer

Hi, I'm trying to add a column to a report to retrieve the last login data from AAD/Graph using the script posted here but i'm running into the ... [0].signInActivity.lastSignInDateTime # Assign a column value to $Context.Value $Context.Value = $lastLogonDate

asked Feb 22 by richarddewis (240 points)
0 votes
1 answer

We would like to have a report of not-disabled users and with user that have a exchange mailbox inside a business unit but for all business units. We now generate ... way to generate the diagramm chart automatically to show the user per business unit? Thanks

asked Mar 3, 2020 by maca (100 points)
0 votes
1 answer

I am wondering what the expected behavior is, and what troubleshooting can be done, for this issue: We have a few tenants listed under Cloud Services > Office 365 We ... know, but they don't have access to force the license update themselves. Thanks, Jason

asked Jan 9, 2019 by Jasonmh (540 points)
0 votes
1 answer

I have a scheduled task that exports the members from a Business unit. However the number of members in the Business Unit (4648), does not equal the number of rows ... of where else I could look to determine the discrepancy, I would greatly appreciate it.

asked Aug 11, 2016 by sandramnc (790 points)
0 votes
1 answer

What is the easiest way to reset the license calculation for ADAXES back to say a new installation? We've unmanaged (manually) a number of accounts and we'd like to add ... that would allow us to simply "start over" in terms of licensing. Thanks in advance.

asked Oct 19, 2016 by VTPatsFan (610 points)
2,740 questions
2,474 answers
6,475 comments
1,372,171 users