unable to assign a admin roles to admin unit

Marin Marinov 161 Reputation points
2024-03-06T16:34:28.53+00:00

Hi guys, I`m trying to assign a Helpdesk Administrator to admin unite. Here is the code I used.

$administrativeUnitId = "314fa520-1456-4205-bb5e-667f0b80646d"
	$adeleVanceId = "7fd45bd8-8f5a-4347-83d5-8c5b1967c74d"
	$userAdministratorRoleId = "729827e3-9c14-49f7-bb1b-9608f156bbb8"
	$params = @{
		roleId = $userAdministratorRoleId
		roleMemberInfo = @{
			id = $adeleVanceId
		}
	}
	
	New-MgDirectoryAdministrativeUnitScopedRoleMember -AdministrativeUnitId $administrativeUnitId -BodyParameter $params

Here is the error I got:

	New-MgDirectoryAdministrativeUnitScopedRoleMember_Create: 
Line |
  11 |      New-MgDirectoryAdministrativeUnitScopedRoleMember -Administrative …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Resource '729827e3-9c14-49f7-bb1b-9608f156bbb8' does not exist or one of its queried reference-property objects are not present.

Status: 404 (NotFound)
ErrorCode: Request_ResourceNotFound
Date: 2024-03-06T16:08:00

Headers:
Cache-Control                 : no-cache
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : 8a132167-536a-4679-bf3c-ea150471b4aa
client-request-id             : b5cfa6ed-aba1-46e2-964f-cad971d41c1f
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"Italy North","Slice":"E","Ring":"5","ScaleUnit":"002","RoleInstance":"MI3PEPF000001BD"}}
x-ms-resource-unit            : 1
Date                          : Wed, 06 Mar 2024 16:07:59 GMT

PS B:\PowerShell>

I`m walking in circles for the past 2 hours. I suspect that it has something to do with the license I'm using.

May I ask you for help?

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
3,999 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,913 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,951 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Marin Marinov 161 Reputation points
    2024-03-06T16:46:07.01+00:00

    I have found the solution, In deed it`s happening because I have no premium license.

    0 comments No comments

  2. Shweta Mathur 28,201 Reputation points Microsoft Employee
    2024-03-07T06:04:50.8566667+00:00

    @Marin Marinov

    Thanks for reaching out.

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to "Accept" the answer.

    User's image

    0 comments No comments