Friday, May 15, 2026

Add Co-Owner to a Power Automate Flow Using PowerShell

Power Automate flows are often built by one person but need to be managed by a team. Adding a co-owner gives another user full edit access — they can modify, run, share, and delete the flow. In this guide, we walk through how to add a co-owner to any Power Automate flow using PowerShell and the Power Apps Administration module.

1. What is a Co-Owner in Power Automate?

A co-owner in Power Automate has the same permissions as the original flow owner. They can edit and modify the flow, turn it on or off, view run history, add or remove other owners, and delete the flow.

This is different from a Run-only user, who can only trigger the flow but cannot edit or manage it.

2. Prerequisites

Before running the script, make sure you have the following:

  • Power Platform Admin or Environment Admin role assigned to your account
  • PowerShell 5.1 or later (PowerShell 7+ recommended)
  • Internet access to connect to Microsoft services
  • The Flow ID and Environment ID from the flow's browser URL
💡 Tip: The Flow ID and Environment ID are visible directly in the browser URL when you open the flow details page:

https://make.powerautomate.com/environments/{EnvironmentId}/flows/{FlowId}/details

3. Install Required PowerShell Modules

Run the following commands in PowerShell as Administrator:

# Power Apps Administration module
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -AllowClobber

# Az module (to retrieve your Azure AD Object ID)
Install-Module -Name Az -Force -AllowClobber

4. Connect to Power Platform

Authenticate to both Power Apps and Azure. A browser window will open for interactive login — sign in with your Microsoft 365 / Azure AD account.

# Sign in to Power Platform
Add-PowerAppsAccount

# Sign in to Azure (to retrieve your Object ID)
Connect-AzAccount

5. Get Your Azure AD Object ID

Every user in Azure Active Directory has a unique Object ID. This is what the API uses to identify who to assign as co-owner.

# Get the Object ID of the currently signed-in user
$myObjectId = (Get-AzADUser -SignedIn).Id
Write-Host "Your Object ID: $myObjectId"

To add someone else as co-owner, look up by their email address instead:

# Get Object ID by UPN (email)
$myObjectId = (Get-AzADUser -UserPrincipalName "user@yourdomain.com").Id

6. Add Co-Owner Using PowerShell

Use Set-AdminFlowOwnerRole to assign the co-owner role. Set RoleName to CanEdit for full co-owner access, or CanView for read-only access.

$EnvironmentName = "default-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$FlowId          = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Set-AdminFlowOwnerRole `
    -EnvironmentName   $EnvironmentName `
    -FlowName          $FlowId `
    -RoleName          "CanEdit" `
    -PrincipalType     "User" `
    -PrincipalObjectId $myObjectId

Write-Host "Co-owner added successfully!" -ForegroundColor Green

7. Verify the Co-Owner Was Added

After running the script, confirm the role was assigned correctly by listing all current owners:

Get-AdminFlowOwnerRole `
    -EnvironmentName $EnvironmentName `
    -FlowName        $FlowId

You should see an entry with your Object ID and RoleName: CanEdit in the output.

8. Full Script

# ============================================================
# Add Co-Owner to Power Automate Flow via PowerShell
# Modules required: Microsoft.PowerApps.Administration.PowerShell, Az
# ============================================================

# Step 1: Install modules (run once as Administrator)
# Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
# Install-Module -Name Az -Force

# Step 2: Authenticate
Add-PowerAppsAccount
Connect-AzAccount

# Step 3: Get your Object ID
$myObjectId = (Get-AzADUser -SignedIn).Id
Write-Host "Object ID: $myObjectId"

# Step 4: Set flow details (replace with your actual values)
$EnvironmentName = "default-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$FlowId          = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

# Step 5: Add as Co-Owner
Set-AdminFlowOwnerRole `
    -EnvironmentName   $EnvironmentName `
    -FlowName          $FlowId `
    -RoleName          "CanEdit" `
    -PrincipalType     "User" `
    -PrincipalObjectId $myObjectId

Write-Host "Done! Co-owner added successfully." -ForegroundColor Green

# Step 6: Verify
Get-AdminFlowOwnerRole `
    -EnvironmentName $EnvironmentName `
    -FlowName        $FlowId

9. Common Errors & Fixes

Error Cause Fix
Get-AzureADCurrentUser not recognized Old AzureAD module not installed Use Get-AzADUser -SignedIn from the Az module
Forbidden / 403 error Account lacks admin rights Ensure you have Environment Admin or Power Platform Admin role
Flow not found / 404 Wrong Flow ID or not authenticated Re-run Add-PowerAppsAccount and verify the Flow ID in the URL
Unapproved verbs WARNING Module internal naming convention This is harmless — the command still executes correctly

Summary: Using the Microsoft.PowerApps.Administration.PowerShell module, you can programmatically manage flow ownership without needing UI access. This is especially useful for admins managing flows at scale, or for recovering access when the original owner has left the organization.

No comments:

Post a Comment

Featured Post

Add Co-Owner to a Power Automate Flow Using PowerShell

Power Automate flows are often built by one person but need to be managed by a team. Adding a co-owner gives another user full edit access ...

Popular posts