msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Remove-MgGroupMemberByRef 2.17.0 missing DirectoryObjectId parameter

Open WillPowerIsAll opened this issue 1 year ago • 13 comments

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

WillPowerIsAll avatar Apr 09 '24 01:04 WillPowerIsAll

I'm facing the same problem.

lorisAmbrozzo avatar Apr 09 '24 06:04 lorisAmbrozzo

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

bhoogerv avatar Apr 09 '24 07:04 bhoogerv

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

timayabi2020 avatar Apr 09 '24 07:04 timayabi2020

Thank you, Remove-MgGroupMemberDirectoryObjectByRef is working nicely.

bhoogerv avatar Apr 09 '24 08:04 bhoogerv

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

LeonarddeR avatar Apr 09 '24 08:04 LeonarddeR

@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.

timayabi2020 avatar Apr 09 '24 12:04 timayabi2020

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

kpinel avatar Apr 17 '24 00:04 kpinel

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?

WillPowerIsAll avatar Apr 18 '24 12:04 WillPowerIsAll

It's right here: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.groups/remove-mggroupmemberdirectoryobjectbyref?view=graph-powershell-1.0

salbeck-sit avatar Apr 18 '24 12:04 salbeck-sit

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.

vtancredi-PNC avatar Apr 24 '24 00:04 vtancredi-PNC

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?

sjm12 avatar Apr 27 '24 16:04 sjm12

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.

samuelt81 avatar May 02 '24 17:05 samuelt81

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.

kpinel avatar May 06 '24 22:05 kpinel