Skip to content

Get-ConnectionRoleAssignment

PowerApps: Retrieves connection role assignments

#Requires -Version 5.1
#Requires -Modules Microsoft.PowerApps.PowerShell

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [pscredential]$PACredential,

    [string]$ConnectionName,
    [string]$ConnectorName,
    [string]$EnvironmentName,
    [string]$PrincipalObjectId,
    [string]$ApiVersion,

    [ValidateSet('*', 'PrincipalDisplayName', 'RoleName', 'RoleId', 'PrincipalEmail', 'ConnectionName', 'ConnectorName', 'EnvironmentName', 'PrincipalObjectId', 'PrincipalType', 'RoleType', 'Internal')]
    [string[]]$Properties = @('PrincipalDisplayName', 'RoleName', 'RoleId', 'PrincipalEmail', 'ConnectionName', 'ConnectorName', 'EnvironmentName')
)

Process {
    try {
        ConnectPowerApps4Creators -PAFCredential $PACredential

        $getArgs = @{ ErrorAction = 'Stop' }

        if ($PSBoundParameters.ContainsKey('ApiVersion')) { $getArgs.Add('ApiVersion', $ApiVersion) }
        if ($PSBoundParameters.ContainsKey('EnvironmentName')) { $getArgs.Add('EnvironmentName', $EnvironmentName) }
        if ($PSBoundParameters.ContainsKey('ConnectorName')) { $getArgs.Add('ConnectorName', $ConnectorName) }
        if ($PSBoundParameters.ContainsKey('ConnectionName')) { $getArgs.Add('ConnectionName', $ConnectionName) }
        if ($PSBoundParameters.ContainsKey('PrincipalObjectId')) { $getArgs.Add('PrincipalObjectId', $PrincipalObjectId) }

        $result = Get-PowerAppConnectionRoleAssignment @getArgs -ErrorAction Stop | Select-Object $Properties

        if ($null -ne $result) {
            foreach ($item in $result) {
                $item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force
            }
        }
    }
    catch { throw }
    finally { DisconnectPowerApps4Creators }
}

PowerApps credentials for authentication

The connection identifier

The connector identifier

The connection's environment

Object ID of a user or group to filter by

API version to call

Properties to retrieve. Use * for all.

An interactive directory of PowerShell scripts.