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

Remove-MgGroupMemberByRef 2.17.0 missing DirectoryObjectId parameter #2670

Closed
WillPowerIsAll opened this issue Apr 9, 2024 · 13 comments · Fixed by #2721
Closed

Remove-MgGroupMemberByRef 2.17.0 missing DirectoryObjectId parameter #2670

WillPowerIsAll opened this issue Apr 9, 2024 · 13 comments · Fixed by #2721

Comments

@WillPowerIsAll
Copy link

WillPowerIsAll commented Apr 9, 2024

Describe the bug

The parameter -DirectoryObjectId is not available with the command Remove-MgGroupMemberByRef in the module Microsoft.Graph.Groups 2.17.0.

The Microsoft.Graph.Groups 2.16.0 have the -DirectoryObjectId parameter.

To Reproduce
Steps to reproduce the behavior:

  1. Open PowerShell 7.4.1 as a user
  2. Install-Module -Name Microsoft.Graph -MaximumVersion 2.17.0 -Force -Confirm:$false -Scope CurrentUser
  3. Connect-MgGraph -Scopes "User.Read.All", "Group.Read.All", "GroupMember.Read.All", "GroupMember.ReadWrite.All"
  4. Remove-MgGroupMemberByRef -GroupId 123 -DirectoryObjectId
    Remove-MgGroupMemberByRef: A parameter cannot be found that matches parameter name 'DirectoryObjectId'.

Expected behavior

The parameter -DirectoryObjectId is supposed to be available with the command Remove-MgGroupMemberByRef in the module Microsoft.Graph.Groups 2.17.0.

Module Version

Get-Module Microsoft.Graph*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.17.0                Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…}
Script     2.17.0                Microsoft.Graph.Groups              {Add-MgGroupDriveListContentTypeCopy, Add-MgGroupDriveListContentTypeCopyFromContentTypeHub, Add-MgGroupFavorite, Add-MgGroupSite…}

Environment Data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Screenshots
MgGraphError

@lorisAmbrozzo
Copy link

I'm facing the same problem.

@bhoogerv
Copy link

bhoogerv commented Apr 9, 2024

I am on 2.17 (psversion 5.1) and also have the issue.

@timayabi2020
Copy link
Contributor

Hello @lorisAmbrozzo @WillPowerIsAll thank you for reporting this issue. After checking the paths in the open API file provided by the Microsoft Graph API owner, I noticed that Remove-MgGroupMemberByRef which transalates to /groups/{group-id}/members/$ref doesn't have a directoryObject-id parameter. See image below.

image

Further checks revealed that the API endpoint containing the missing parameter is /groups/{group-id}/members/{directoryObject-id}/$ref which transalates to Remove-MgGroupMemberDirectoryObjectByRef cmdlet. See image below.
image

There for the correct cmdlets to use are Remove-MgGroupMemberDirectoryObjectByRef and Remove-MgBetaGroupMemberDirectoryObjectByRef

@bhoogerv
Copy link

bhoogerv commented Apr 9, 2024

Thank you, Remove-MgGroupMemberDirectoryObjectByRef is working nicely.

@LeonarddeR
Copy link

Is it normal for such backwards incompatible changes to be made to Graph without mentioning it in any release notes?

@timayabi2020
Copy link
Contributor

@LeonarddeR Thanks for seeking further clarity on this matter. To answer your question. No, it's not normal. I have gone through their change log once again and unfortunately was not able to trace the changes related to this particular issue. I will follow up with the API owner on this issue.

@kpinel
Copy link

kpinel commented Apr 17, 2024

Still seeing this in our Azure automation and the modules haven't been updated yet.
I need to schedule an outage to roll back our modules to 2.16

@WillPowerIsAll
Copy link
Author

WillPowerIsAll commented Apr 18, 2024

I don't get why the issue is closed. The version 2.17.0 still does not have the DirectoryObjectId parameter and the documentation is still not up to date.

Can you tel me where the correct cmdlet (Remove-MgGroupMemberDirectoryObjectByRef) is documented?

@vtancredi-PNC
Copy link

Hello @lorisAmbrozzo @WillPowerIsAll thank you for reporting this issue. After checking the paths in the open API file provided by the Microsoft Graph API owner, I noticed that Remove-MgGroupMemberByRef which transalates to /groups/{group-id}/members/$ref doesn't have a directoryObject-id parameter. See image below.

image

Further checks revealed that the API endpoint containing the missing parameter is /groups/{group-id}/members/{directoryObject-id}/$ref which transalates to Remove-MgGroupMemberDirectoryObjectByRef cmdlet. See image below. image

There for the correct cmdlets to use are Remove-MgGroupMemberDirectoryObjectByRef and Remove-MgBetaGroupMemberDirectoryObjectByRef

Fantastic work, thank you, this works for me. Must be a recent change within the last 2 months because the old command used to work for me at that time.

@sjm12
Copy link

sjm12 commented Apr 27, 2024

I am trying to use the Remove-MgGroupMemberDirectoryObjectByRef -GroupId $groupId -DirectoryObjectId $userId to remove users from a group. It works fine when using an account that has global admin permissions but using a service principal with (GroupMember.ReadWrite.All Directory.ReadWrite.All, Group.ReadWrite.All) I get error "Insufficient privileges to complete the operation"

What other permissions is required?

@samuelt81
Copy link

I am trying to use the Remove-MgGroupMemberDirectoryObjectByRef -GroupId $groupId -DirectoryObjectId $userId to remove users from a group. It works fine when using an account that has global admin permissions but using a service principal with (GroupMember.ReadWrite.All Directory.ReadWrite.All, Group.ReadWrite.All) I get error "Insufficient privileges to complete the operation"

What other permissions is required?

Same issue. I have 'UserAuthenticationMethod.ReadWrite.All','User.ReadWrite.All','GroupMember.ReadWrite.All','Group.ReadWrite.All','Directory.ReadWrite.All' and none of them let me use the command. Worth saying I am using a Global Admin account.

@kpinel
Copy link

kpinel commented May 6, 2024

Noticed that the cmdlet has changed with 2.18.0 to Remove-MgGroupMemberDirectoryObjectByRef, noted by samuelt81
The original cmdlet Remove-MgGroupMemberByRef is still broken.

If this cmdlet has changed, that means a lot of rewriting of runbooks. I could understand this with a major version change, but a point version seems a bit rediculous.

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.

10 participants