Skip to content

New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef error #1616

@William-Francillette

Description

@William-Francillette

The cmdlet New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef returns an error when using bodyparameter as descibed in the following documentation :https://learn.microsoft.com/en-us/graph/api/accesspackage-post-incompatiblegroup?view=graph-rest-beta&tabs=powershell

However when using the odataID parameter it worked as expected - find the debug trace below

$ref = @{
                '@odata.id' = "https://graph.microsoft.com/beta/groups/4825df30-727a-4165-9e51-2c7160736353"
            }
  New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef `
                -AccessPackageId '5d05114c-b4d9-4ae7-bda6-4bade48e60f2' `
                -BodyParameter $ref -debug
DEBUG: [CmdletBeginProcessing]: - New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef begin processing with parameterSet 'Create'.
DEBUG: [Authentication]: - AuthType: 'AppOnly', AuthProviderType: 'ClientCredentialProvider', ContextScope: 'Process', AppName: 'M365DSC'.
DEBUG: [Authentication]: - Scopes: [Policy.Read.ConditionalAccess, DeviceManagementManagedDevices.Read.All, Policy.ReadWrite.ConditionalAccess, User.ReadWrite.All, RoleManagement.Read.Directory, Policy.ReadWrite.ApplicationConfiguration, Application.ReadWrit
e.All, Group.Read.All, Directory.ReadWrite.All, DeviceManagementServiceConfig.Read.All, Group.ReadWrite.All, Directory.Read.All, User.Read.All, Agreement.Read.All, DeviceManagementServiceConfig.ReadWrite.All, GroupMember.Read.All, Organization.ReadWrite.All,
 DeviceManagementConfiguration.Read.All, DeviceManagementManagedDevices.ReadWrite.All, User.ManageIdentities.All, Organization.Read.All, RoleManagement.ReadWrite.Directory, GroupMember.ReadWrite.All, Policy.Read.All, DeviceManagementConfiguration.ReadWrite.A
ll, Application.Read.All, DeviceManagementApps.ReadWrite.All, DeviceManagementApps.Read.All, EntitlementManagement.Read.All, EntitlementManagement.ReadWrite.All].
DEBUG: [CmdletException]: Received exception with message 'ArgumentException - An item with the same key has already been added. :    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.Graph.PowerShell.Runtime.Json.JsonObject.Add(String name, JsonNode value)
   at Microsoft.Graph.PowerShell.Runtime.Extensions.AddIf[T](T value, String serializedName, Action`2 addMethod)
   at Microsoft.Graph.PowerShell.Models.ReferenceCreate.ToJson(JsonObject container, SerializationMode serializationMode)
   at Microsoft.Graph.PowerShell.IdentityGovernance.<IdentityGovernanceEntitlementManagementAccessPackagesCreateIncompatibleGroupsGraphBPreRef>d__1715.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.PowerShell.Cmdlets.NewMgEntitlementManagementAccessPackageIncompatibleGroupByRef_Create.<ProcessRecordAsync>d__58.MoveNext()'
New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef : An item with the same key has already been added.
At line:2 char:13
+             New-MgEntitlementManagementAccessPackageIncompatibleGroup ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-MgEntitleme...oupByRef_Create], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.NewMgEntitlementManagementAccessPackageIncompatibleGroupByRef_Create
 
DEBUG: [CmdletEndProcessing]: - New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef end processing.

The following command worked correctly:

New-MgEntitlementManagementAccessPackageIncompatibleGroupByRef `
                -AccessPackageId '5d05114c-b4d9-4ae7-bda6-4bade48e60f2' `
                -OdataId "https://graph.microsoft.com/beta/groups/4825df30-727a-4165-9e51-2c7160736353"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions