Skip to content

Can't Use Update-MgTenant... GDAP API Cmdlets Due to Required If-Match Header Not Exposed in Parameters #2328

Closed

Description

Describe the bug

It is not possible to successfully execute an Update-MgTenantRelationshipDelegatedAdminRelationship or Update-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment cmdlet because these PATCH operations require an If-Match header to validate the ETag value of the existing object, and there is no way to pass that value to these two cmdlets.

To Reproduce
Steps to reproduce the behavior:
$CurrentAccessAssignment = Get-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment -DelegatedAdminRelationshipId $GDAPRelationship.Id -Filter "AccessContainer/AccessContainerId eq '$($GroupId)' and Status eq 'active'";$AccessAssignmentParameters = @{ DelegatedAdminRelationshipId = $GDAPRelationship.Id DelegatedAdminAccessAssignmentId = ($CurrentAccessAssignment.Id) AccessDetails = $AccessDetails ErrorAction = "Continue" }; $AccessAssignment = Update-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment @AccessAssignmentParameters

Expected behavior

The updated delegated admin access assignment object returned to the output.

Debug Output
DEBUG: [CmdletBeginProcessing]: - Update-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment begin processing with parameterSet 'UpdateExpanded'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'Process', AppName: 'ProArch GDAP Manager - Beta'.
DEBUG: [Authentication]: - Scopes: [DelegatedAdminRelationship.ReadWrite.All, User.Read, profile, openid, email].

Confirm
Are you sure you want to perform this action?
Performing the operation "Update-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment_UpdateExpanded" on target
"Call remote 'PATCH
/tenantRelationships/delegatedAdminRelationships/{delegatedAdminRelationship-id}/accessAssignments/{delegatedAdminAccessAs
signment-id}' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PATCH

Absolute Uri:
https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships/xxxxxx/accessAssignments/xxxxxx

Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22621; en-US),PowerShell/2023.6.0
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.6.1
client-request-id : f4b852c2-27cb-4285-abcd-e6c8fb3a75f0

Body:
{
"accessDetails": {
"unifiedRoles": [
{
"roleDefinitionId": "xxxxxxxx"
},
{
"roleDefinitionId": "xxxxxxxx"
}
]
}
}

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
PreconditionRequired

Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 9a00e94e-d36e-4369-8fd1-0e1d8c6332b3
client-request-id : f4b852c2-27cb-4285-abcd-e6c8fb3a75f0
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"East US","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"BL4PEPF0000029C"}}
Date : Thu, 28 Sep 2023 12:44:24 GMT

Body:
{
"error": {
"code": "preconditionRequired",
"message": "A precondition is required.",
"details": [],
"innerError": {
"code": "entityTagMissing",
"message": "The If-Match header or the ETag value in the header is missing.",
"target": null,
"details": [],
"date": "2023-09-28T12:44:25",
"request-id": "9a00e94e-d36e-4369-8fd1-0e1d8c6332b3",
"client-request-id": "f4b852c2-27cb-4285-abcd-e6c8fb3a75f0"
}
}
}

Update-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment_UpdateExpanded: C:\Users\JacobReinhardt\OneDrive - ProArch\Documents\Projects\GDAP Bulk Migration\ProarchGDAPManager\Invoke-GDAPRoleAssignment.ps1:92:13
Line |
92 | $AccessAssignment = Update-MgTenantRelationshipDelegatedA …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| A precondition is required. Status: 428 (PreconditionRequired) ErrorCode: preconditionRequired Date:
| 2023-09-28T12:44:25 Headers: Transfer-Encoding : chunked Vary :
| Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id :
| 9a00e94e-d36e-4369-8fd1-0e1d8c6332b3 client-request-id : f4b852c2-27cb-4285-abcd-e6c8fb3a75f0
| x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"East
| US","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"BL4PEPF0000029C"}} Date :
| Thu, 28 Sep 2023 12:44:24 GMT
DEBUG: [CmdletEndProcessing]: - Update-MgTenantRelationshipDelegatedAdminRelationshipAccessAssignment end processing.

Module Version
Name : Microsoft.Graph.Authentication
Path : C:\Users\JacobReinhardt\OneDrive - ProArch\Documents\PowerShell\Modules\Microsoft.Graph.Authentication
\2.6.1\Microsoft.Graph.Authentication.psm1
Description : Microsoft Graph PowerShell Authentication Module.
ModuleType : Script
Version : 2.6.1
PreRelease :
NestedModules : {Microsoft.Graph.Authentication, Microsoft.Graph.Authentication.Core}
ExportedFunctions : {Find-MgGraphCommand, Find-MgGraphPermission}
ExportedCmdlets : {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…}
ExportedVariables :
ExportedAliases : {Connect-Graph, Disconnect-Graph, Invoke-GraphRequest, Invoke-MgRestMethod}

Name : Microsoft.Graph.Identity.Partner
Path : C:\Users\JacobReinhardt\OneDrive - ProArch\Documents\PowerShell\Modules\Microsoft.Graph.Identity.Partn
er\2.6.1\Microsoft.Graph.Identity.Partner.psm1
Description : Microsoft Graph PowerShell Cmdlets
ModuleType : Script
Version : 2.6.1
PreRelease :
NestedModules : {Microsoft.Graph.Identity.Partner.private, Microsoft.Graph.Identity.Partner.custom}
ExportedFunctions : {Get-MgTenantRelationshipDelegatedAdminCustomer, Get-MgTenantRelationshipDelegatedAdminCustomerCount,
Get-MgTenantRelationshipDelegatedAdminCustomerServiceManagementDetail,
Get-MgTenantRelationshipDelegatedAdminCustomerServiceManagementDetailCount…}
ExportedCmdlets :
ExportedVariables :
ExportedAliases :

Environment Data
Name Value


PSVersion 7.3.7
PSEdition Core
GitCommitId 7.3.7
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Screenshots
"Line |
92 | $AccessAssignment = Update-MgTenantRelationshipDelegatedA …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| A precondition is required. Status: 428 (PreconditionRequired) ErrorCode: preconditionRequired Date:
| 2023-09-28T12:29:01 Headers: Transfer-Encoding : chunked Vary :
| Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id :
| 8ba1ed98-3911-4226-863e-bae5ead25ced client-request-id : 0b60e036-6e77-4614-be05-3e79b379b206
| x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"East
| US","Slice":"E","Ring":"5","ScaleUnit":"004","RoleInstance":"BL02EPF00009A94"}} Date :
| Thu, 28 Sep 2023 12:29:00 GMT"

Additional context
Reference the underlying API documentation to see that the If-Match header is required for both operations: https://learn.microsoft.com/en-us/graph/api/delegatedadminrelationship-update?view=graph-rest-1.0&tabs=http and https://learn.microsoft.com/en-us/graph/api/delegatedadminaccessassignment-update?view=graph-rest-1.0&tabs=http. I note that the Remove-MgTenant... equivalents do have an "IfMatch" parameter, and therefore the pattern in present to account for this but that the Update-MgTenant cmdlets appear to have been overlooked.

Activity

  1. changed the title [-]Can't Use Update-MgTenant... GDAP API Cmdlets Due to Required If-Match Header Not Exposed in Parameterss[/-] [+]Can't Use Update-MgTenant... GDAP API Cmdlets Due to Required If-Match Header Not Exposed in Parameters[/+] on Sep 28, 2023
  2. hnougher commented on Oct 18, 2023

    @hnougher

    Agreed. Needs an If-Match to be usable.
    I assume this would be its usage.
    -If-Match $assignment.AdditionalProperties['@odata.etag']

  3. peombwa commented on Oct 18, 2023

    @peombwa
    Member

    Thanks for bringing this to our attention.

    The header is missing in the service description (CSDL metadata) that the SDK is built on top of. I've transferred the issue to the appropriate repo at microsoftgraph/msgraph-metadata#463 for this to be fixed.

    As workaround, you can look at using Invoke-MgGraphRequest to bypass the missing If-Match header:

    Invoke-MgGraphRequest -Uri "v1.0/tenantRelationships/delegatedAdminRelationships/xxxxxx/accessAssignments/xxxxxx" -Method PATCH -Body $RequestBody -Headers @{ "If-Match" = $CurrentAccessAssignment.AdditionalProperties['@odata.etag']}
  4. peombwa commented on Oct 18, 2023

    @peombwa
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions