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.