Notifications
Announcements
Microsoft.PowerApps.Administration.PowerShell
# Install the necessary modules if not already installed Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Scope CurrentUser Install-Module -Name Microsoft.Xrm.Data.PowerShell -Scope CurrentUser # Import the modules Import-Module Microsoft.PowerApps.Administration.PowerShell Import-Module Microsoft.Xrm.Data.PowerShell # Define the environment URL and user details $environmentUrl = "https://your_environment.crm.dynamics.com" $environmentId = "your_environment_id" $userEmail = "user@example.com" $securityRoles = @("Environment Admin", "Environment Maker") # Replace with actual role names # Authenticate to Power Platform Add-PowerAppsAccount # Add the user to the environment New-AdminPowerAppEnvironmentUser -EnvironmentName $environmentId -UserPrincipalName $userEmail # Authenticate to the Dataverse environment $connection = Get-CrmConnection -InteractiveMode -ServerUrl $environmentUrl # Get the user's system user ID $userId = (Get-CrmRecords -conn $connection -EntityLogicalName systemuser -FilterAttribute domainname -FilterOperator eq -FilterValue $userEmail).CrmRecords[0].systemuserid # Assign security roles to the user foreach ($roleName in $securityRoles) { $roleId = (Get-CrmRecords -conn $connection -EntityLogicalName role -FilterAttribute name -FilterOperator eq -FilterValue $roleName).CrmRecords[0].roleid New-CrmRecord -conn $connection -EntityLogicalName systemuserroles -Fields @{ systemuserid = $userId; roleid = $roleId } } Write-Host "User added and roles assigned successfully."
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 711 Most Valuable Professional
Michael E. Gernaey 319 Super User 2025 Season 2
Power Platform 1919 268