Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several cmdlets don't report the right count when 1 owner/member #418

Closed
joshtransient opened this issue Oct 6, 2020 · 3 comments · Fixed by #542
Closed

Several cmdlets don't report the right count when 1 owner/member #418

joshtransient opened this issue Oct 6, 2020 · 3 comments · Fixed by #542
Assignees
Milestone

Comments

@joshtransient
Copy link

joshtransient commented Oct 6, 2020

On both 5.1 and 7, run:

$owners = Get-MgGroupOwner -GroupId <ID of a Group with one owner>
$owners.Count

$members = Get-MgGroupMember -GroupId <ID of a Group with one member>
$members.Count

Both .Count lines will return 2 instead of 1. .GetType() returns MicrosoftGraphDirectoryObject, and not an array. I'm using $owners.Id.Count and $members.Id.Count to get correct counts in the meantime.

Same for Get-MgDirectoryDeletedItem. The only way I get a usable object I can enumerate against is to run $deletedItems = (Get-MgDirectoryDeletedItem -DirectoryObjectId 'microsoft.graph.group').ToJsonString() | ConvertFrom-Json
AB#6870

@joshtransient joshtransient changed the title Get-MgGroupOwner and Get-MgGroupMember don't report the right count when 1 owner/member Several cmdlets don't report the right count when 1 owner/member Oct 6, 2020
@ryanspletzer
Copy link

Bumping this one, I've experienced this as well.

@ryanspletzer
Copy link

It also occurs with something like this when filtering for a single object:

$u = Get-MgUser -Filter "displayName eq 'Ryan Spletzer'"
$u.Count # 0

There is a Count property set on that outputted object and it returns 0.

@peombwa
Copy link
Member

peombwa commented Dec 11, 2020

@joshtransient, @ryanspletzer Thanks for reporting this to us. This is indeed a bug. Count property shouldn't be present when a command returns an object. We will fix this in the next release.

Note to self:

  • The same should apply to Keys and Values properties.

@peombwa peombwa self-assigned this Dec 11, 2020
@peombwa peombwa added the Bug label Dec 11, 2020
@peombwa peombwa added this to the 1.3.0 milestone Dec 11, 2020
@peombwa peombwa modified the milestones: 1.3.0, 1.4.0 Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants