Add a User to Power Platform and Assign a Custom Role via PowerShell
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.
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.
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.
Open PowerShell as Administrator and run 'Install-Module -Name Microsoft.PowerApps.Administration.PowerShell' to install the required tools, then import it using 'Import-Module'.
Execute the command 'Add-PowerAppsAccount' to prompt the authentication window. Log in using your Power Platform administrator credentials.
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.
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.
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.
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. Download the Installer: Visit the official WPS Office website and click the free download button to get the latest version.
- 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. Open and Edit Your Files: Launch WPS Office and instantly open your existing Word, Excel, or PowerPoint files without worrying about formatting issues.

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.




