Set-ConnectionRoleAssignment-Admin
PowerApps Admin: Sets a connection role assignment
#Requires -Version 5.1
#Requires -Modules Microsoft.PowerApps.Administration.PowerShell
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[pscredential]$PACredential,
[Parameter(Mandatory = $true)]
[string]$ConnectionName,
[Parameter(Mandatory = $true)]
[string]$ConnectorName,
[Parameter(Mandatory = $true)]
[string]$EnvironmentName,
[Parameter(Mandatory = $true)]
[string]$PrincipalObjectId,
[Parameter(Mandatory = $true)]
[ValidateSet('CanView', 'CanViewWithShare', 'CanEdit')]
[string]$RoleName,
[Parameter(Mandatory = $true)]
[ValidateSet('User', 'Group', 'Tenant')]
[string]$PrincipalType,
[string]$ApiVersion
)
Process {
try {
ConnectPowerApps -PAFCredential $PACredential
$args = @{ ErrorAction = 'Stop'; ConnectionName = $ConnectionName; ConnectorName = $ConnectorName; EnvironmentName = $EnvironmentName; RoleName = $RoleName; PrincipalType = $PrincipalType; PrincipalObjectId = $PrincipalObjectId }
if ($PSBoundParameters.ContainsKey('ApiVersion')) { $args.Add('ApiVersion', $ApiVersion) }
$result = Set-AdminPowerAppConnectionRoleAssignment @args -ErrorAction Stop | Select-Object PrincipalDisplayName, RoleName, RoleId, PrincipalEmail, ConnectionName, ConnectorName, EnvironmentName
if ($null -ne $result) { $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force }
}
catch { throw }
finally { DisconnectPowerApps }
}PowerApps credentials
The connection identifier
The connection's connector name
The connection's environment
Object ID of the user/group/tenant
Permission: CanView, CanViewWithShare, CanEdit
Type: User, Group, Tenant
API version to call