logo
search
Others

Add a User to Power Platform and Assign a Custom Role via PowerShell

Maira MehtabMaira Mehtab Sep 22, 2026 868 views

Question details

The user needs a method to programmatically add a user to a Power Platform environment using PowerShell and assign a specific custom security role without utilizing environment security groups.

Product
Microsoft Power Platform
Device & OS
not provided
Scenario
Automating user provisioning and permission assignment in Power Platform environments.
Observed behavior
The administrator requires the exact administrative commands and API workflow to successfully provision the user and attach the custom role directly.
Before you start

Ensure you have the latest Microsoft PowerApps Administration PowerShell modules installed on your system and that your account holds System Administrator privileges in the target Dataverse environment.

Solution 1Recommended

Provision User and Assign Role via Power Platform PowerShell

Use the standard Power Platform administrative modules to authenticate, add the user, and execute Dataverse web API requests to assign the role by its unique ID.

This process requires a combination of the PowerApps Administration module to add the user to the environment and Dataverse API calls to link the custom security role. Since you are bypassing security groups, the role assignment is handled explicitly at the user level.

Custom security roles are stored in the Dataverse 'roles' table. You will need to query this table to find the specific Role ID before making the assignment.

1
Install and Import Required Modules

Open PowerShell as Administrator and run 'Install-Module -Name Microsoft.PowerApps.Administration.PowerShell' to install the required tools, then import it using 'Import-Module'.

2
Authenticate to Power Platform

Execute the command 'Add-PowerAppsAccount' to prompt the authentication window. Log in using your Power Platform administrator credentials.

3
Add User to the Environment

Use the 'Add-AdminPowerAppEnvironmentUser' cmdlet, specifying the 'EnvironmentName' (the environment's GUID) and the 'PrincipalObjectId' (the Azure AD Object ID of the user) to add the user.

4
Retrieve the Custom Role ID

Use Dataverse Web API requests via the 'Invoke-RestMethod' or specialized Dataverse PowerShell modules to query the 'roles' table and filter by your custom role name to obtain the role's unique GUID.

5
Assign the Custom Role to the User

Perform an API POST request to the 'systemuserroles_association' relationship in Dataverse, linking the newly added user's SystemUserId with the Role ID retrieved in the previous step.

Community Support: For specialized assistance with exact script syntax or API error handling, it is highly recommended to post your complete script layout and error messages in the Microsoft Power Platform Community.
Free Microsoft Office alternative

Need a Lightweight Alternative for Office Document Management?

While Microsoft Power Platform handles complex enterprise app environments, you might need a fast, reliable, and free suite for managing your daily administrative documents, scripts, and spreadsheet reports. WPS Office offers an intuitive interface and robust features without the heavy resource usage.

  1. 1. Download the Installer: Visit the official WPS Office website and click the free download button to get the latest version.
  2. 2. Install the Software: Run the downloaded installer file and follow the quick on-screen instructions to set up WPS Office on your device.
  3. 3. Open and Edit Your Files: Launch WPS Office and instantly open your existing Word, Excel, or PowerPoint files without worrying about formatting issues.
Fully compatible with Microsoft Office formats (.docx, .xlsx, .pptx) for your administrative reports.Lightweight design ensures fast installation and snappy performance during daily tasks.Generate and review PowerShell script documentation easily using WPS Writer.Completely free to use for all essential office functions with seamless cloud integration.
microsoft office alternative - wps office

Frequently Asked Questions

Can I assign a Power Platform role without using an Azure AD security group?

Yes, roles can be assigned directly to individual users using PowerShell and Dataverse API endpoints, which bypasses the need to manage roles through environment security groups.

Which PowerShell module is required for Power Platform administration?

You need to install the 'Microsoft.PowerApps.Administration.PowerShell' module to manage environments, users, and administrative tasks via the command line.

How do I find the Role ID for a custom security role?

You can query the Dataverse 'roles' table using the Web API to filter by the specific custom role name. The response will return the unique GUID associated with that role.

Why isn't the Add-AdminPowerAppEnvironmentRoleAssignment command working for custom roles?

Certain administrative cmdlets are optimized for built-in roles. Assigning custom security roles programmatically often requires direct interaction with the Dataverse Web API to link the user and role records.