web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Security
Unanswered

Rank priority

(0) ShareShare
ReportReport
Posted on by
 
Categories:
I have the same question (0)
  • TT-26111713-0 Profile Picture
    4 on at
    Rank priority
    Create a CSV file named users.csv with the following content
    UserEmail,RoleName

    user1@domain.com,Basic User
    user2@domain.com,System Administrator
    user3@domain.com,Sales Manager
    ------
    # 1. Install module (only 1 time)
    Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
    Install-Module -Name Microsoft.PowerApps.PowerShell -Force
    # 2. Login tenant
    Add-PowerAppsAccount

    # 3. Find Env name
    Get-AdminPowerAppEnvironment | select DisplayName, EnvironmentName
    -----
    Paste script

    $envName = "<your-environment-name>"
    $csvPath = "C:\users.csv"
    $users = Import-Csv $csvPath
    foreach ($u in $users) {
        Write-Host "==== Processing $($u.UserEmail) ====" -ForegroundColor Cyan
        $userObj = Get-AdminPowerAppUser -EnvironmentName $envName | `
                    Where-Object { $_.Email -eq $u.UserEmail }
        if ($null -eq $userObj) {
            Write-Host "❌ User not found in environment: $($u.UserEmail)" -ForegroundColor Red
            continue
        }
        $role = Get-AdminPowerAppRole -EnvironmentName $envName | `
                Where-Object { $_.DisplayName -eq $u.RoleName }
        if ($null -eq $role) {
            Write-Host "❌ Role not found: $($u.RoleName)" -ForegroundColor Red
            continue
        }
        Add-AdminPowerAppRoleAssignment `
            -EnvironmentName $envName `
            -PrincipalId $userObj.ObjectId `
            -RoleId $role.RoleId
        Write-Host "✅ Added role '$($u.RoleName)' to $($u.UserEmail)" -ForegroundColor Green
    }
    ---Just in case error
    Get-ExecutionPolicy -List
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
  • TT-26111713-0 Profile Picture
    4 on at
    Rank priority
     

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.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 64

#2
Fubar Profile Picture

Fubar 46 Super User 2025 Season 2

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 27 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics