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

by (216k points)
Best answer
0 votes

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

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, 2024 by PeterS (40 points)
0 votes
1 answer

Hey we have a multi-domain AD forest and I'm trying to use powershell to remove computers in the child domains from a universal group in the root domain. I tried it with naming ... I run this in Ps5.1 or Ps7, from my laptop or from the Adaxes server itself.

asked 14 hours ago by felix (210 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, 2024 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, 2024 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