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 (216k 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

Is there a way to extend the Get-AdmGroupMember for easier cloud user management and better expressing the actual "user" object your working with? https://www ... -60d8-49a9-aebb-0000000000 SID : S-1-15-000000000000-3621557498-1235837144-3060644782-00000000000

asked Apr 1 by PeterS (40 points)
0 votes
1 answer

In most situations in Adaxes when multiple members are added or removed from a group the members are processed individually allowing business rules to run for each of them. ... a business rule to get information about the other members added with the cmdlet?

asked Mar 8 by Carl Bruinsma (120 points)
0 votes
1 answer

Hello, I understand it is possible to do time based group memberships when using the the Privileged Access Management Feature with the Windows 2016 functional level of ... com/script-repository/temporary-group-membrship-s533.htm the only option at the time?

asked Jan 31 by Daniel (160 points)
0 votes
1 answer

Hi, I was wondering if there was a way to generate a widget type block/or a report on the Adaxes homepage displaying the number of free licences for a specific (or all) ... are the most important information if there's a way to report on that. Thanks, Gary

asked Feb 8, 2023 by gazoco (490 points)
0 votes
1 answer

We have a 3rd party vendor that we are able to add users based on AD security groups. What I need to do is set a parameter for the number of available licenses and whenever ... the group is 495 I would like an email to trigger telling me to add more licenses.

asked Oct 12, 2022 by A_Pastor (70 points)
3,589 questions
3,278 answers
8,303 comments
548,117 users